Android自定义Layout
在開發Android過程中,有時已有的Loyout布局不能完全滿足設計需求,這時需要在已有的Layout基礎上上進行擴展,以達到通過配置文件描述布局的設計原則。
首先第一一個布局類,重寫其onDraw方法。
Java代碼??
?其次,在布局配置文件中引用:
<?xml version="1.0" encoding="utf-8"?>
?
<view xmlns:android="http://schemas.android.com/apk/res/android"
class="iRelativeLayout"
?? ?android:orientation="vertical"
?? ?android:layout_width="fill_parent"
?? ?android:layout_height="fill_parent"
?? ?android:background = "#C5CCD4FF"
>
<LinearLayout
android:id = "@+id/TabLayout_One"
android:layout_width = "fill_parent"
android:layout_height = "fill_parent"
android:layout_above = "@+id/Tabs"
>
<ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content">
<RelativeLayout
android:layout_width = "fill_parent"
android:layout_height = "fill_parent"
android:visibility = "visible"
>
<Button
android:id = "@+id/ButtonOne"
android:layout_width = "wrap_content"
android:layout_height = "fill_parent"
android:text = "h3h3h3"
/>
<Button
android:id = "@+id/ButtonTwo"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text = "11222"
android:layout_below ="@+id/ButtonOne"
/>
<Button
android:id = "@+id/ButtonThree"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text = "wass"
android:layout_below ="@+id/ButtonTwo"
/>
</RelativeLayout>
</ScrollView>
</LinearLayout>
</view>
最后,和其他布局一樣使用即可。
總結
以上是生活随笔為你收集整理的Android自定义Layout的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android开发-将自定义View布局
- 下一篇: Android之在Layout中自定义V