- Colors.xml
<resources> <item name="colorPrimary" type="color">#0b811b</item> <item name="colorPrimaryDark" type="color">#bfda0a</item> <item name="colorAccent" type="color">#000000</item> </resources>
You want to use this format when you are customizing your color palette. On the first line where it says #0b811b, this is a color in hexadecimal which you can find easily online. You can use whatever hexadecimal color you want, these are just examples. Either you can use hexadecimal colors or you can use the colors in Android Studio. To access the Android Studio colors, you click on one of your activities and click on the ‘Design’ tab at the bottom. Once you are here, if you click on an item you got from the palette, then you will a list on the right of the screen. If you look all the way down at the bottom of the list, there should be a box for ‘textcolor’. You want to click on the three buttons the right of it and there is where you can select colors.
2. Coding buttons
First, you want to go on “Design” for the page you want to have a button on, and then you can adjust anything you want to for the size,background color, etc. Next, you want to go to the “Java file” for the page/activity your button is on.
package PUT YOURS HERE; import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; public class MainActivity extends AppCompatActivity { /* Create java variables */ public Button mBtLaunchActivity; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* Initialize java Button objects to point to UI elements */ mBtLaunchActivity = (Button) findViewById(R.id.but1); /* Tell each button what you want it to do when you press it */ mBtLaunchActivity.setOnClickListener(new View.OnClickListener() @Override public void onClick(View view) { launchActivity(); } }); } /* Define actual switching methods */ private void launchActivity() { Intent intent = new Intent(this, Main2activity.class); startActivity(intent); } }
Anything in Italic is what I used in my code but you may have something else. For example, the activity that my button is on is called “Main Activity” but you might have named it something else. “Main Activity 2 or Main2Activity” is the page/activity I want the button to go to when someone clicks the button. Anything between the /**/ are just comments explaining what the different things mean/do. Also, but1 is just the name of my button so you don’t have to use that name for the your button. Then you want to go your AndroidManifest.xml file to put some stuff in there.
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="SAME ONE YOU USED IN THE JAVA FILE"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action."/> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".Main2activity"></activity> </application> </manifest>
The MainActivity is the page the button is on and Main2Activity is the page I want my button to go to once it is clicked. Also, the xml version and the encoding on the first line might be different for yours.
If you want to have two buttons on the same page, make sure you double everything in the java file except for the imports, public class, package, and the @Override showed below.
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
Make sure that in the manifest file you only put the other name for the other activity that your second button is going to. Put the second activity name right under the first one so it should look like this:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="YOUR PACKAGE NAME HERE"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action."/> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".Main2activity"></activity> <activity android:name=".Sign_up"></activity> </application> </manifest>
Main2activty is where my first button is going and Sign_up is where my second button is going to when it’s clicked. Also, MainActivity is the activity that both my buttons are on. The two activities should be together in the “application” tags.
3. Making a SwipeView
I am currently struggling with this but here are some websites. If you figure out how to do it, please comment down below. Enjoy.
https://developer.android.com/design/patterns/swipe-views.html
https://www.infsoft.com/technology/sensors/bluetooth-low-energy-beaconshttps://dzone.com/articles/android-tutorial-using
https://dzone.com/articles/android-tutorial-dynamicaly
https://developer.android.com/training/implementing-navigation/lateral.html
Creating a Beacon App for Android in Less Than 10 Minutes from Scratch
https://github.com/Eajy/MaterialDesignDemohttps://github.com/codepath/android_guides/wiki/ViewPager-with-FragmentPagerAdapter