當前位置:首頁 » 安卓系統 » android分割線

android分割線

發布時間: 2022-01-12 13:48:24

⑴ android studio 分割線左右邊距怎麼設置

重新檢查下java_HOME,PATH,CLASSPATH。。我安裝android Studio的時候也出現過你這情況,設置好了JAVA_HOME,PATH,CLASSPATH之後就能啟動了

⑵ 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"

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

⑶ android怎樣在布局中顯示分割線

在設計Android應用時,設置分隔線的方法一:


在需要設置分隔線的布局文件中加入如下代碼:

<View

android:layout_width="fill_parent"

android:layout_height="1px"

android:background="?android:attr/listDivider"

/>


運行實際結果如下:

⑷ Android怎麼實現Linearlayout的垂直分割線

方法一:使用一個View設置background屬性放置在兩個控制項之間

<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:gravity="center"
android:orientation="horizontal">

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"/>

<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@drawable/divider"/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"/>

</LinearLayout>

可以看到每個button之間都有了分割線

⑸ android listview 的item 分割線高度問題

android:divider="#ffffff"
android:dividerHeight="1dp"

一個設置分割線的顏色,一個設置分割線的高度

⑹ android 如何設置listview的分割線為虛線

使用Shape來畫。

在Shape的根結點設置幾何形狀android:shape=「line"
shape標簽下的stroke標簽有幾個屬性:
android:dashWidth 虛線的寬度。
android:dashGap 虛線之間的間隔即「 - - - - 」
如果不會用,可以搜索一下相關屬性。
不過4.0以後並無虛線效果,看起來還是實線,4.0以前才會顯示虛線。

⑺ 如何創建一個View的分割線

1 人工添加LinearLayout的分割線

我們可以創建一個View,這個View就是分割線,只要簡單在Button之間添加這個分割線就可以。
分割線的實現,如下:

<View android:layout_height="fill_parent" android:layout_width="1dp" android:background="#90909090" android:layout_marginBottom="5dp" android:layout_marginTop="5dp"/>

So the whole layout, as pictured, becomes:
<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" 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" 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" android:text="Neutral" android:layout_weight="1" android:id="@+id/button3" android:textColor="#00b0e4" /> </LinearLayout>

2 在LinearLayout定義divider
你可以給LinearLayout設置a view divider,這很明顯是個很好的解決方法,尤其是不知道LinearLayout下有多少個子Button。
這種必須是在API level 11 或者更高的API版本使用。
我們先定義這個分割線樣式吧:
<?

把這個分割線的樣式設置給LinearLayout:
<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" 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" 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" android:text="Neutral" android:layout_weight="1" android:id="@+id/button3" android:textColor="#00b0e4" /> </LinearLayout>

其中最重要當然就是:
android:divider="@drawable/separator"android:showDividers="middle"

3給容器組件設置ButtonBarStyle (默認是分割線,最容易實現方法)

As danialgoodwin mentioned in the comments, adding the buttonBarStyle to the LinearLayout will show default separators. This is also for api level 11 or higher only.
The important part here, is adding this line to the LinearLayout:
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:dividerPadding="15dp" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New Button" android:id="@+id/button1" android:layout_gravity="center_vertical" /> <!-- more buttons/views --> </LinearLayout>

You can also adjust the paddings of the view separators with the 「dividerPadding」 setting.

Button使用的相同的檢舉,所以他們之間的間距也是相同的。
當然你可為分割線設置漸變色。
轉載僅供參考,版權屬於原作者。祝你愉快,滿意請採納哦

⑻ android preferenceactivity中的分割線可以去掉嗎

還是不要用preferenceActivity,
就用普通的activity好了。
祝你愉快,滿意請採納哦

⑼ android中設置分隔線有幾種方法

方法一

也是我們常用的方法,可以在按鈕間添加作為分割線的View,設定好View的寬度高度和顏色值後插入按鈕的布局間。

View的樣式如下:

android:layout_height="fill_parent"

android:layout_width="1dp"

android:background="#90909090"

android:layout_marginBottom="5dp"

android:layout_marginTop="5dp"

/>

⑽ androidstudio怎麼設置分割線

android studio設置分割線的話,在xml布局文件裡面,你可以使用view,這是寬度或者高度為1px就行。

熱點內容
學考密碼重置要求的證件是什麼 發布:2024-09-20 07:19:46 瀏覽:476
電腦主伺服器怎麼開機 發布:2024-09-20 07:19:07 瀏覽:727
2022款瑞虎升級哪些配置 發布:2024-09-20 06:59:07 瀏覽:263
資料庫與asp 發布:2024-09-20 06:55:25 瀏覽:726
python解釋編譯 發布:2024-09-20 06:52:57 瀏覽:647
舞蹈豐收腳本 發布:2024-09-20 06:36:26 瀏覽:595
linux進程埠號 發布:2024-09-20 06:36:11 瀏覽:79
派派怎麼改密碼忘了 發布:2024-09-20 06:25:49 瀏覽:780
linux虛擬地址物理地址 發布:2024-09-20 06:23:29 瀏覽:564
大華監控雲存儲 發布:2024-09-20 06:13:24 瀏覽:597