2011年8月18日木曜日

複数の要素(View)を重ねて表示【android】【FrameLayout】【重ねて表示】

次回に下記をカスタマイズした記事があります。
⇒複数の要素(View)を重ねて表示の続き

画像に重ねて文字を出力したいときなど、Viewを重ねて表示する場合には、
FrameLayout』を使用します。

SDカードの画像格納ディレクトリ一覧を表示する画面をイメージしたレイアウトが
下記になります。
後から宣言されたViewが上に表示されます。


















■custom_list_item.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"
android:layout_height="fill_parent">

<ListView android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#00000000"
/>

</FrameLayout>
 
 
■custom_list_item.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="2dip"
android:paddingBottom="2dip"
android:paddingLeft="2dip"
android:paddingRight="2dip">

<ImageView
android:id="@+id/imageview"
android:layout_width="50dip"
android:layout_height="50dip"
android:scaleType="centerCrop"
android:padding="2dip"
android:layout_gravity="left"
/>

<TextView android:id="@+id/textview"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_gravity="left"
android:layout_marginLeft="2dip"
android:layout_marginTop="2dip"
android:textColor="@color/white"
android:textSize="35dip"
android:textStyle="bold"
/>

</FrameLayout>

0 件のコメント:

コメントを投稿