如何添加(垂直)分频器水平的LinearLayout? [英] How to add (vertical) divider to a horizontal LinearLayout?

查看:130
本文介绍了如何添加(垂直)分频器水平的LinearLayout?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想添加一个分压器水平线性布局,但我一事无成。分频器只是不显示。我是一个总的新手与Android。

这是我的布局XML:

 < RelativeLayout的的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    的xmlns:工具=htt​​p://schemas.android.com/tool​​s
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    工具:上下文=MainActivity。>

    <的LinearLayout
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
        机器人:ID =@ + ID / llTopBar
        机器人:方向=横向
        机器人:分隔=#00FF00
        机器人:dividerPadding =22dip
        机器人:showDividers =中间
       >

        <按钮
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =match_parent
            机器人:文本=ASDF/>
            <按钮
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =match_parent
            机器人:文本=ASDF
             />

    < / LinearLayout中>

< / RelativeLayout的>
 

解决方案

使用的水平分割

 <查看
    机器人:layout_width =1DP
    机器人:layout_height =match_parent
    机器人:背景=@色/ honeycombish_blue/>
 

这对于垂直分隔

 <查看
    机器人:layout_width =match_parent
    机器人:layout_height =1DP
    机器人:背景=@色/ honeycombish_blue/>
 

或者如果您使用的LinearLayout分,对于水平分割

 < XML版本=1.0编码=UTF-8&GT?;
<形状的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
    <大小机器人:身高=1DP/>
    [固体机器人:颜色=#f6f6f6/>
< /形状>
 

和中的LinearLayout

 < LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:分隔=@可绘制/除法
    机器人:方向=垂直
    机器人:showDividers =中间>
 

如果你想用户垂直分隔然后在机器人:身高=1DP的形状使用机器人:宽=1DP

I'm trying to add a divider to a horizontal linear layout but am getting nowhere. The divider just doesn't show. I am a total newbie with Android.

This is my layout XML:

<RelativeLayout xmlns: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"
    tools:context=".MainActivity" >

    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/llTopBar"
        android:orientation="horizontal"
        android:divider="#00ff00"
        android:dividerPadding="22dip"
        android:showDividers="middle"
       >

        <Button
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:text="asdf" />
            <Button
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:text="asdf"
             />

    </LinearLayout>

</RelativeLayout>

解决方案

use this for horizontal divider

<View
    android:layout_width="1dp"
    android:layout_height="match_parent"
    android:background="@color/honeycombish_blue" />

and this for vertical divider

<View
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="@color/honeycombish_blue" />

OR if you can use the LinearLayout divider, for horizontal divider

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <size android:height="1dp"/>
    <solid android:color="#f6f6f6"/>
</shape>

and in LinearLayout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:divider="@drawable/divider"
    android:orientation="vertical"
    android:showDividers="middle" >

If you want to user vertical divider then in place of android:height="1dp" in shape use android:width="1dp"

这篇关于如何添加(垂直)分频器水平的LinearLayout?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆