我正在使用TabLayout,我有自定义图像用于我正在使用的选项卡,但对于我的生活,我无法弄清楚如何更改选项卡和选项卡内容之间的分隔符的颜色甚至图像.我试图使用setDividerDrawable(),但是在我设置选项卡内容之前调用它时会崩溃,而在我之后调用它时什么都不做.如果我能把它变成黑色就足够了,但到目前为止还没有任何效果.谢谢你的指导.
我正在尝试设置要在我的应用程序列表中使用的分隔符。我已经为“diceddivider”制作了 XML 代码,如下所示
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:width="1px"
android:color="@color/divider_Color"
/>
</shape>
Run Code Online (Sandbox Code Playgroud)
然后我试图将它设置为我的 LinearLayout 的可绘制分隔符,如下所示
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
diceCount = 0;
diceList = (LinearLayout) this.findViewById(R.id.main_Dice_List);
diceList.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
diceList.setDividerDrawable(this.getResources().getDrawable(R.drawable.dicedivider));
diceList.setDividerPadding(5);
addDice();
}
Run Code Online (Sandbox Code Playgroud)
尽管如此,该应用程序没有显示分隔符。我什至尝试将它直接嵌入到 XML 中,但没有任何运气。
我对 Android 编码很陌生。知道我哪里出错了吗?
android divider android-linearlayout xml-drawable android-drawable
我PopupMenu在我的应用程序中使用了几个s,它们都按预期工作
但是我希望将白色线条分开,但我无法找到我想要设置的位置.我希望我可以访问底层的ListView,但这似乎不可能.我也看不到与分隔线相关的样式项.
这可能吗,我应该在哪里/如何设置?
customization android divider android-layout android-popupwindow
我试图将边距设置为默认导航抽屉的“ divider ”属性。我以Stackoverflow形式发现了许多方法,但是没有一个答案是足够的。
我可以创建自定义导航抽屉列表,而无需使用/menu/activity_main_drawer.xml。看起来像我想要的。但是我对应用程序的性能感到担心。
我想补充保证金到默认的分隔符。有没有一种方法可以自定义默认的导航抽屉分隔线?
style.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:listDivider">@color/colorAccent</item>
...
</style>
Run Code Online (Sandbox Code Playgroud)
divider_layout.xml
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetLeft="60dp"
android:insetRight="8dp" >
<shape>
<solid android:color="#c0c0c0" />
</shape>
</inset>
Run Code Online (Sandbox Code Playgroud)
activity_main_drawer.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_camera"
android:icon="@drawable/rakipicon"
android:title="Import" />
<item
android:id="@+id/nav_gallery"
android:icon="@drawable/ic_menu_gallery"
android:title="Gallery" />
<item
android:id="@+id/nav_slideshow"
android:icon="@drawable/ic_menu_slideshow"
android:title="Slideshow" />
<item
android:id="@+id/nav_manage"
android:icon="@drawable/ic_menu_manage"
android:title="Tools" />
</group>
<item android:title="Communicate">
<menu>
<item
android:id="@+id/nav_share"
android:icon="@drawable/ic_menu_share"
android:title="Share" />
<item
android:id="@+id/nav_send" …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用空列作为a中列对之间的分隔符JTable.这是我到目前为止的图片和代码.我知道我可以使用自定义更改外观TableCellRenderer.在我走这条路之前,还有更好的方法吗?任何想法都赞赏.
TablePanel.png http://i42.tinypic.com/1zxpfkj.png
import javax.swing.*;
import javax.swing.table.*;
public class TablePanel extends JPanel {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JFrame f = new JFrame("TablePanel");
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.add(new TablePanel());
f.pack();
f.setVisible(true);
}
});
}
public TablePanel() {
TableModel dataModel = new MyModel();
JTable table = new JTable(dataModel);
table.getColumnModel().getColumn(MyModel.DIVIDER).setMaxWidth(0);
JScrollPane jsp = new JScrollPane(table);
jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
this.add(jsp);
}
private static class MyModel extends AbstractTableModel {
private static final int DIVIDER = 2; …Run Code Online (Sandbox Code Playgroud) TabWidget下的android:divider属性是否有效?我试过android的Tab Layout教程只是为了测试(http://developer.android.com/resources/tutorials/views/hello-tabwidget.html)并将android:divider设置为某个图像(现在我用的是android垂直滚动条作为drawable真正强调它是否被拾取(从框架中复制),但是当我在模拟器上运行它时,它似乎没有工作.根据文档,TabWidget似乎支持这个attribute:"Drawable用于在制表符之间绘制分隔符."
有人可以帮忙吗?我正在使用九补丁的drawable作为我的分隔图像drawable.
MB
我在listview中添加了一个可绘制的分隔符,但除最后一项之外的所有项目都显示了该分隔符.
我在列表中只有5个项目,所以在最后一个项目后面的所有空白区域,我想在最后一个项目之后有一个分隔符
我试过这个:
android:footerDividersEnabled="true"
Run Code Online (Sandbox Code Playgroud)
在我的列表视图中.但它没有用
谢谢
我希望在a的顶部有一个分隔符ListView(放在其中RelativeLayout),但是当我尝试使用它时,我只得到底部分隔符:
<ListView
android:id="@+id/last_contacts_picked_list"
android:headerDividersEnabled="true"
android:footerDividersEnabled="true"
android:paddingTop="50dp"
android:dividerHeight="5dp"
android:layout_marginTop="50dp"
android:divider="@android:drawable/divider_horizontal_textfield"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="..."
android:layout_alignLeft="..."
android:layout_alignRight="..."
android:layout_below="..."
/>
Run Code Online (Sandbox Code Playgroud)
我有这样的事情:
http://i051.radikal.ru/1211/4f/a408db5e717f.png
为什么它也没有标题分隔符呢?
我试图在风格divider的ListView.我想要的只是2条简单的水平线.
list.xml
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/ListView" >
</ListView>
Run Code Online (Sandbox Code Playgroud)
styles.xml
<style name="ListView" parent="android:style/Widget.ListView">
<item name="android:divider">@drawable/divider</item>
<!-- 5dp: just to make sure there's enough space -->
<item name="android:dividerHeight">5dp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
divider.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#00ffff" />
<size android:height="1dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="#ff0000" />
<size android:height="1dp" />
</shape>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
结果是一条水平线height of 5dp(应该是2,不是吗?)和color of red(第二项的颜色).第一个带颜色的项目#00ffff根本没有显示.
有人可以建议2个简单的水平线的代码?
在我的应用程序中,我正在使用AutoCompleteTextView.其中一个要求是隐藏分隔符.我已将AutoCompleteTextView添加到布局:
<AutoCompleteTextView
android:id="@id/address_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginRight="8dp"
android:layout_toLeftOf="@id/address_operation_btn"
android:background="@null"
android:completionThreshold="1"
android:dropDownAnchor="@id/anchor"
android:dropDownVerticalOffset="13dp"
android:dropDownWidth="wrap_content"
android:ellipsize="end"
android:gravity="center"
android:layout_centerHorizontal="true"
android:hint="@string/address_bar_hint"
android:imeOptions="actionGo"
android:inputType="textUri"
android:maxLines="1"
android:saveEnabled="true"
android:singleLine="true"
android:dropDownListViewStyle="@style/searchResultsList"
android:textColor="@android:color/white"
android:textColorHint="#80FFFFFF"
android:textSize="17sp" />
Run Code Online (Sandbox Code Playgroud)
我正在使用的风格是
<style name="searchResultsList" parent="@android:style/Widget.ListView">
<item name="android:divider">@android:color/transparent</item>
<item name="android:dividerHeight">0px</item>
</style>
Run Code Online (Sandbox Code Playgroud)
但是分频器还在那里......如果可以隐藏?