xml - How do I layout two EditTexts side by side to each other in a GridLayout? -
i have 2 edittexts. i'd each take half of ui screen width.
below xml layout file. leftmost edittext ("due date") showing i'm clearing missing here. rightmost edittext should showing "due time". please advise.
.... <android.support.design.widget.textinputlayout android:id="@+id/duedate_text_input_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_row="4" android:layout_column="0"> <com.example.jdw.thirdscreen.listeneredittext android:id="@+id/fedittext" android:hint="due date" android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_weight="1" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:layout_gravity="start" android:inputtype="text|textcapsentences|textnosuggestions" android:textappearance="?android:attr/textappearancemedium" android:textcolor="#ffffff" android:singleline="true" android:maxlength="51" android:imeoptions="actionnext|flagnoextractui" android:layout_marginbottom="8dp" android:nextfocusright="@+id/duetime_text_input_layout" > </com.example.jdw.thirdscreen.listeneredittext> </android.support.design.widget.textinputlayout> <android.support.design.widget.textinputlayout android:id="@+id/duetime_text_input_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_row="4" android:layout_column="1"> <com.example.jdw.thirdscreen.listeneredittext android:id="@+id/gedittext" android:hint="due time" android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_weight="1" android:layout_alignparentright="true" android:layout_alignparentend="true" android:layout_gravity="start" android:inputtype="text|textcapsentences|textnosuggestions" android:textappearance="?android:attr/textappearancemedium" android:textcolor="#ffffff" android:singleline="true" android:maxlength="51" android:imeoptions="actionnext|flagnoextractui" android:layout_marginbottom="8dp" android:nextfocusdown="@+id/savebutton" > </com.example.jdw.thirdscreen.listeneredittext> </android.support.design.widget.textinputlayout> ...
use weight
property, available since api 21
<gridlayout 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:orientation="horizontal" tools:context=".mainactivity" android:rowcount="4" android:columncount="2"> <edittext android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/edittext" android:layout_gravity="fill_horizontal" android:layout_columnweight="1" /> <edittext android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/edittext2" android:layout_gravity="fill_horizontal" android:layout_columnweight="1" /> </gridlayout>
Comments
Post a Comment