I am using Linear Layout for this xml file :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
>
<EditText
android:id="@+id/editTextUserNameToLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="User Name">
<requestFocus />
</EditText>
<EditText
android:id="@+id/editTextPasswordToLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Password"
android:inputType="textPassword" />
<Button
android:id="@+id/buttonSignIn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Sign In" />
<ToggleButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New ToggleButton"
android:id="@+id/toggleButton"/>
</LinearLayout>
I want all text views to appear in the center of the screen, except for the the toggle button which i want it to be in the right-bottom of the screen.
As you can see, i am using android:gravity
center in the layout's tag, because neither this nor android:layout_gravity
was working on individual textviews.
But now i want toggle button to be independent of this. How can i achieve it?
You can use relative layout look this code how you can set your xml as per your requirement.
This is it what you want. Thanks