ホーム > タグ > レイアウト
レイアウト
[Android] レイアウトでViewを両端に配置する方法
- 2012-06-22 (金)
 - 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>
				
- Comments: 0
 - Trackbacks: 0
 
[Android] ページ内でのListView区切り線表示
- 2012-03-02 (金)
 - Android
 
レイアウトを作成していると区切り線を表示したいという場面に出くわすことがちょこちょこあります。いろいろと工夫することでそれっぽい見た目を実現することは可能ですが面倒・・・ということで、簡単に実現する方法について。
- Comments: 0
 - Trackbacks: 0
 
Home > Tags > レイアウト
- Search
 - Feeds
 - Meta
 - 人気の記事