android - centerVertical won't work with a fragment -
i made simple fragment 2 edit texts in it. then, tried add image button. want fragment in center of activity , worked fine. however, image button won't in center of fragment below 2 edit texts. why won't centervertical work fragments? here xml code login view xml file:
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" 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 main xml file:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" 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>
change fragment's layout params in main.xml to
android:layout_width="match_parent" android:layout_height="match_parent"
Comments
Post a Comment