【发布时间】:2014-12-18 12:17:23
【问题描述】:
我已经建立了这个仪表板(见附件)
我要做的是为按钮创建一个“按下状态”。改变颜色对我来说很好。
仪表板按钮由 5 个相对布局组成,每个布局包含两个图像视图和两个文本视图。
下面列出的代码仅用于本例中的一个按钮“移动应用程序”:
<RelativeLayout
android:id="@+id/appsHolder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/gradient_background"
android:padding="5dp" >
<!-- ListRow Left sied Thumbnail image -->
<LinearLayout
android:id="@+id/thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="5dip"
android:padding="3dip" >
<ImageView
android:id="@+id/list_image"
android:layout_width="150dip"
android:layout_height="150dip"
android:src="@drawable/ic_apps_dashboard" />
</LinearLayout>
<!-- Title Of Song -->
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/thumbnail"
android:layout_toRightOf="@+id/thumbnail"
android:text="Mobile Apps"
android:textColor="#000000"
android:textSize="30dip"
android:textStyle="bold"
android:typeface="sans" />
<!-- Artist Name -->
<TextView
android:id="@+id/subtitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:layout_marginTop="1dip"
android:layout_toRightOf="@+id/thumbnail"
android:text="Preview the Viessmann apps..."
android:textColor="#000000"
android:textSize="30dip" />
<!-- Rightend Duration -->
<!-- Rightend Arrow -->
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_arrow_dashboard" />
</RelativeLayout>
我们将不胜感激!
【问题讨论】:
-
使用
StateList选择器作为RelativeLayout 背景。
标签: android android-layout android-xml android-custom-view android-ui