android layout allignment issue -
i want put "type 1" , "type 2" in same line , make on center. means everything. working on api level 23. trued android:layout_centerhorizontal="true" in inner linearlayout doesn't work
<?xml version="1.0" encoding="utf-8"?> <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" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context="com.example.sid.roommanager.btrancol"> <linearlayout android:id="@+id/linearlayout02" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_alignparenttop="true" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="milliseconds" android:id="@+id/tv_milli" /> <edittext android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/edittext" android:inputtype="number" android:text="1000" /> </linearlayout> <button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="type 1" android:id="@+id/bt_led1" android:layout_below="@+id/linearlayout02" android:layout_marginend="134dp" android:layout_centerhorizontal="true" /> <button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="type 2" android:id="@+id/bt_led2" android:layout_below="@+id/bt_led1" android:layout_centerhorizontal="true" /> </relativelayout>
there many solutions problem. 1 of them given below. use nested <linearlayout>
elements gravity set center_horizontal
:
<?xml version="1.0" encoding="utf-8"?> <linearlayout 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" android:gravity="center_horizontal" android:orientation="vertical" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context="com.example.sid.roommanager.btrancol"> <linearlayout android:id="@+id/linearlayout02" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_horizontal"> <textview android:id="@+id/tv_milli" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="milliseconds" /> <edittext android:id="@+id/edittext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputtype="number" android:text="1000" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal"> <button android:id="@+id/bt_led1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="type 1" /> <button android:id="@+id/bt_led2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="type 2" /> </linearlayout> </linearlayout>
Comments
Post a Comment