Reputation: 161
I'm read Andorid Metrics and Grids (http://developer.android.com/design/style/metrics-grids.html) and now im trying to make my layout looks good. I've got TableRow with two elements TextEdit and button.
<TableRow android:id="@+id/tableRow2" android:layout_width="match_parent" android:layout_height="match_parent">
<EditText
android:id="@+id/personDOB"
android:hint="Date of birth"
android:inputType="date" />
<ImageButton
android:id="@+id/openCalendar"
android:layout_width="48dp"
android:layout_height="wrap_content"
android:background="@drawable/mybutton_background"
android:contentDescription="@string/selectdate"
android:cropToPadding="true"
android:onClick="selectDate"
android:src="@drawable/ic_datepicker"/>
</TableRow>
My button is 32x32 (so i can add margin 8dp each side for 48dp rhytm) but in TableRow it's like 3 times width. I tried making button layout_width = 48dp (as above), wrap content, make some experiments with width=0px & weight but all this doesn't help. I need by button to be fixed size and all other row space must be used by EditText.
Upvotes: 1
Views: 1509
Reputation: 26034
Replace following layout with your one.
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<EditText
android:id="@+id/personDOB"
android:layout_width="0dp"
android:layout_weight="1"
android:hint="Date of birth"
android:inputType="date" />
<ImageButton
android:id="@+id/openCalendar"
android:layout_width="48dp"
android:layout_height="wrap_content"
android:background="@drawable/mybutton_background"
android:contentDescription="@string/selectdate"
android:adjustViewBounds="true"
android:cropToPadding="true"
android:onClick="selectDate"
android:scaleType="centerInside"
android:src="@drawable/ic_datepicker" />
</TableRow>
Upvotes: 1