Created
June 29, 2013 07:02
-
-
Save daichan4649/5890175 to your computer and use it in GitHub Desktop.
GridLayout Sample (EditText/Spinner)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ScrollView | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" > | |
<GridLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:columnCount="3" | |
android:padding="8dip" | |
android:useDefaultMargins="true" > | |
<ImageButton | |
android:id="@+id/play" | |
android:layout_width="@dimen/item_property_voice_width" | |
android:layout_height="@dimen/item_property_voice_width" | |
android:layout_column="0" | |
android:layout_gravity="left" | |
android:src="@android:drawable/ic_media_play" > | |
</ImageButton> | |
<TextView | |
android:layout_column="0" | |
android:layout_gravity="left" | |
android:text="タイトル" | |
android:textColor="#000000" | |
android:textSize="16sp" /> | |
<EditText | |
android:id="@+id/title" | |
android:layout_gravity="fill_horizontal" | |
android:ems="10" | |
android:hint="未入力" | |
android:textColor="#000000" | |
android:textSize="16sp" > | |
</EditText> | |
<ImageButton | |
android:id="@+id/voice_title" | |
android:layout_width="@dimen/item_property_voice_width" | |
android:layout_height="@dimen/item_property_voice_width" | |
android:layout_gravity="top" | |
android:scaleType="fitXY" | |
android:src="@drawable/mic_search" > | |
</ImageButton> | |
<TextView | |
android:layout_column="0" | |
android:layout_gravity="left" | |
android:text="サイズ" | |
android:textColor="#000000" | |
android:textSize="16sp" /> | |
<Spinner | |
android:id="@+id/size" | |
android:layout_width="0dip" | |
android:layout_gravity="fill_horizontal" /> | |
<TextView | |
android:layout_column="0" | |
android:layout_gravity="left" | |
android:text="住所" | |
android:textColor="#000000" | |
android:textSize="16sp" /> | |
<EditText | |
android:id="@+id/address" | |
android:layout_gravity="fill_horizontal" | |
android:ems="10" | |
android:hint="未入力" | |
android:textColor="#000000" | |
android:textSize="16sp" > | |
</EditText> | |
<ImageButton | |
android:id="@+id/voice_address" | |
android:layout_width="@dimen/item_property_voice_width" | |
android:layout_height="@dimen/item_property_voice_width" | |
android:layout_gravity="top" | |
android:scaleType="fitXY" | |
android:src="@drawable/mic_search" > | |
</ImageButton> | |
<TextView | |
android:layout_column="0" | |
android:layout_gravity="left" | |
android:text="X/緯度" | |
android:textColor="#000000" | |
android:textSize="16sp" /> | |
<EditText | |
android:id="@+id/latitude" | |
android:layout_gravity="fill_horizontal" | |
android:hint="未入力" | |
android:inputType="numberDecimal" | |
android:textColor="#000000" | |
android:textSize="16sp" > | |
</EditText> | |
<TextView | |
android:layout_column="0" | |
android:layout_gravity="left" | |
android:text="作成日時" | |
android:textColor="#000000" | |
android:textSize="16sp" /> | |
<TextView | |
android:id="@+id/created_date" | |
android:layout_gravity="fill_horizontal" | |
android:text="2013/01/01" | |
android:textColor="#000000" | |
android:textSize="16sp" /> | |
</GridLayout> | |
</ScrollView> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This generates lot of inconsistent constraints. I can see lots of debug statements:
D/android.support.v7.widget.GridLayout﹕ horizontal constraints: x2-x1>=394, x2-x0<=680, x2-x1<=335 are inconsistent; permanently removing: x2-x0<=680, x2-x1<=335
How to avoid it? I can use left in layout_gravity instead of fill_horizontal but that does not make sure that all views are aligned.