- 2012-06-22 (金) 21:39
- Android
レイアウトでViewを両端に配置する方法はいくつか存在しますが、ここで紹介する方法が一番シンプルで分かりやすい気がします。
方法はコードを見てもらえば一目瞭然ですが、配置する2つのViewの真ん中に「android:layout_weight」を”1″にしたViewを埋め込むだけです。
1 | <? xml version = "1.0" encoding = "utf-8" ?> |
2 | < LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android" |
3 | android:layout_width = "match_parent" |
4 | android:layout_height = "match_parent" |
5 | android:orientation = "vertical" > |
6 |
7 | < LinearLayout |
8 | android:layout_width = "wrap_content" |
9 | android:layout_height = "wrap_content" |
10 | android:layout_margin = "10dp" > |
11 | |
12 | < TextView |
13 | android:layout_width = "wrap_content" |
14 | android:layout_height = "wrap_content" |
15 | android:text = "左" /> |
16 |
17 | < View |
18 | android:layout_width = "wrap_content" |
19 | android:layout_height = "wrap_content" |
20 | android:layout_weight = "1" /> |
21 | |
22 | < TextView |
23 | android:layout_width = "wrap_content" |
24 | android:layout_height = "wrap_content" |
25 | android:text = "右" /> |
26 |
27 | </ LinearLayout > |
28 |
29 | </ LinearLayout > |
関連があると思われる記事:
- [Android] ページ内でのListView区切り線表示
- [Android] TextViewでクリック処理
- [Android] マルチスレッド(その1)
- [Android] テキストへのリンク設定
- [Android] 背景色の設定
- Newer: [Android] Spinnerの基本的な使い方
- Older: [Android] エミュレータと外部とのソケット通信
Comments:0
Trackbacks:0
- Trackback URL for this entry
- http://gacken.com/wp/program/android/1510/trackback/
- Listed below are links to weblogs that reference
- [Android] レイアウトでViewを両端に配置する方法 from ミライニトドケ