新建photoInfo项目,新建tablelayout_demo.xml,将素材图片复制进drawable
完整代码:
<LinearLayoutxmlns: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="@android:color/darker_gray"//背景颜色
android:orientation="vertical"//垂直分布
tools:context=".MainActivity">
<RelativeLayout
style="@style/h_wrap_content"
android:layout_marginTop="10dp">
<TextView
style="@style/ty_style"
android:layout_alignParentLeft="true"
android:layout_marginLeft="10dp"
android:drawableTop="@drawable/clound"
android:gravity="center"
android:text="cloud" />
<TextView
style="@style/ty_style"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:drawableTop="@drawable/bluetooth"
android:gravity="center"
android:text="bluetooth" />
</RelativeLayout>
<RelativeLayout
style="@style/h_wrap_content"
android:layout_marginTop="10dp">
<TextView
style="@style/ty_style"
android:layout_alignParentLeft="true"
android:layout_marginLeft="10dp"
android:drawableTop="@drawable/gesture"
android:gravity="center"
android:text="gesture" />
<TextView
style="@style/ty_style"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:drawableTop="@drawable/gps"
android:gravity="center"
android:text="gps" />
</RelativeLayout>
<RelativeLayout
style="@style/h_wrap_content"
android:layout_marginTop="10dp">
<TextView
style="@style/ty_style"
android:layout_alignParentLeft="true"
android:layout_marginLeft="10dp"
android:drawableTop="@drawable/theme"
android:gravity="center"
android:text="theme" />
<TextView
style="@style/ty_style"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:drawableTop="@drawable/internet"
android:gravity="center"
android:text="internet" />
</RelativeLayout>
<RelativeLayout
style="@style/h_wrap_content"
android:layout_marginTop="10dp">
<TextView
style="@style/ty_style"
android:layout_alignParentLeft="true"
android:layout_marginLeft="10dp"
android:drawableTop="@drawable/language"
android:gravity="center"
android:text="language" />
<TextView
style="@style/ty_style"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:drawableTop="@drawable/notifycation"
android:gravity="center"
android:text="notifycation" />
</RelativeLayout>
</LinearLayout>
Styles 文件内容
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="h_wrap_content">h_wrap_content
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
</style>
<style name="ty_style">
<item name="android:layout_width">180dp</item>
<item name="android:layout_height">110dp</item>
<item name="android:layout_gravity">center</item>
<item name="android:paddingTop">8dp</item>
<item name="android:paddingBottom">8dp</item>
<item name="android:drawablePadding">5dp</item>
<item name="android:background">@android:color/white</item>
</style>
</resources>
<resources>
<string name="app_name">phoneInfo</string>
<string name="menu_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="_cloud">Cloud</string>
<string name="_bluetooth">Bluetooth</string>
<string name="_gesture">Gesture</string>
<string name="_gps">Gps</string>
<string name="_system_info">SystemInfo</string>
<string name="_internet">Internet</string>
<string name="_language">Language</string>
<string name="_set_notifycation">Notifycation</string>
</resources>