導航:首頁 > 操作系統 > androidxml分割線

androidxml分割線

發布時間:2023-03-09 17:48:11

1. android 在xml中設置textview 下劃線

只知道在代碼中設置下劃線:textView.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
真沒用過在xml中設置下劃線的屬性,如果只是要那種效果可以在TextView控制項下面翻一個view當線使用。

2. android分割線設置怎麼弄

方法一也是我們常用的方法,可以在按鈕間添加作為分割線的View,設定好View的寬度高度和顏色值後插入按鈕的布局間。
View的樣式如下:
<View
android:layout_height="fill_parent"
android:layout_width="1dp"
android:background="#90909090"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
/>

相應的布局如下:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:orientation="horizontal">

<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/buttonBarButtonStyle"
android:text="Yes"
android:layout_weight="1"
android:id="@+id/button1"
android:textColor="#00b0e4" />

<View android:layout_height="fill_parent"
android:layout_width="1px"
android:background="#90909090"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:id="@+id/separator1" />

<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/buttonBarButtonStyle"
android:text="No"
android:layout_weight="1"
android:id="@+id/button2"
android:textColor="#00b0e4" />

<View android:layout_height="fill_parent"
android:layout_width="1px"
android:background="#90909090"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:id="@+id/separator2" />

<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/buttonBarButtonStyle"
android:text="Neutral"
android:layout_weight="1"
android:id="@+id/button3"
android:textColor="#00b0e4" /></LinearLayout>

方法二
通過LinearLayout指定的divider的屬性來插入分隔符,類似於Listview的效果。這種方法的好處在於縮減布局代碼量,同時在button數量未知的情況下能更方便的進行顯示。但是這種方法只適用API版本11以上的機型。
使用方法也很簡單,先創建分隔線的樣式文件
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android">
<size android:width="1dp" />
<solid android:color="#90909090" /></shape>

再在布局文件中引用
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:divider="@drawable/separator"
android:showDividers="middle"
android:orientation="horizontal">

<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/buttonBarButtonStyle"
android:text="Yes"
android:layout_weight="1"
android:id="@+id/button1"
android:textColor="#00b0e4" />

<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/buttonBarButtonStyle"
android:text="No"
android:layout_weight="1"
android:id="@+id/button2"
android:textColor="#00b0e4" />

<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/buttonBarButtonStyle"
android:text="Neutral"
android:layout_weight="1"
android:id="@+id/button3"
android:textColor="#00b0e4" /></LinearLayout>

最主要的代碼如下
android:divider="@drawable/separator"
android:showDividers="middle"

當然分隔線的樣式也可以用圖片來替代,這就看項目的需求了。

閱讀全文

與androidxml分割線相關的資料

熱點內容
安卓光遇怎麼轉ios服 瀏覽:398
android展示文本 瀏覽:208
比特幣命令 瀏覽:956
pythonweb開發實戰常式 瀏覽:316
android圖片自動裁剪圖片 瀏覽:906
程序員閃退怎麼解決 瀏覽:526
看小視頻APP什麼秀 瀏覽:163
linuxping源地址 瀏覽:738
編程語言的優點與缺點 瀏覽:980
台灣歷史pdf 瀏覽:826
貸款簡訊提醒源碼 瀏覽:114
喬家的兒女在什麼app播 瀏覽:340
javalicense實現 瀏覽:376
mysql創建資料庫命令 瀏覽:990
紅色的魚是什麼app 瀏覽:685
程序員的生涯經歷 瀏覽:437
納粹命令 瀏覽:590
什麼講鬼故事app 瀏覽:969
程序員級升 瀏覽:89
怎樣關閉照片加密 瀏覽:524