- 2012-06-22 (金) 21:39
- Android
レイアウトでViewを両端に配置する方法はいくつか存在しますが、ここで紹介する方法が一番シンプルで分かりやすい気がします。
方法はコードを見てもらえば一目瞭然ですが、配置する2つのViewの真ん中に「android:layout_weight」を”1″にしたViewを埋め込むだけです。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="左" />
<View
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="右" />
</LinearLayout>
</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 ミライニトドケ
