I made a simple fragment with two edit texts in it. Then, I tried to add an Image button. I want this fragment to be in the center of the activity and that worked fine. However, the Image button won't get in the center of the fragment below the two edit texts. Why won't centerVertical work with fragments? Here is the xml code for the logIn view xml file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<EditText
android:hint="Type username"
android:id="@+id/userNameText"
android:imeOptions="actionDone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<EditText
android:hint="Type Password"
android:id="@+id/passwordText"
android:layout_below="@id/userNameText"
android:imeOptions="actionDone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/login"
android:onClick="onClick"
android:id="@+id/logInBtn"
android:layout_below="@id/passwordText"
android:layout_centerVertical="true"/>
</RelativeLayout>
and the main xml file:
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.bazar.MainActivity">
<fragment
android:name="com.example.bazar.LogIn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
/>
</RelativeLayout>
Aucun commentaire:
Enregistrer un commentaire