UI TextView菜单模拟按键
布局设置
在Layout_bottom中设置成一排模拟的按键
其中每一个按键实现由一个TextView来模拟,首先Layout_bottom设置的背景为浅蓝色,而TextView在没有选中时,背景图片为空白色,而选中时为深蓝色,从而突出不同的。展示出一个按钮的效果。
TextView实现OnClickListener事件处理,首先要做的处理是在TextView的属性中的clickable设置为true才可以实现OnClickListener事件处理。
最终的效果:
主布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/default_bg"
android:gravity="bottom"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/layout_top"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_weight="2"
android:background="@drawable/bottom"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/text_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textColor="@android:color/black"
android:textSize="24sp" />
</LinearLayout