首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >版面外边框

版面外边框
EN

Stack Overflow用户
提问于 2016-12-14 14:49:57
回答 1查看 2.6K关注 0票数 2

我需要在不修改其大小的情况下将边框设置为linearLayout,我尝试在linearLayout的背景下设置一些可绘制的边框和填充,但这个设置在linearLayout内部,并修改大小、图像和textView。您是否有一种在视图之外设置边框或叠加视图的方法?

我的守则:

代码语言:javascript
运行
复制
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/itemCarouselContainer"
    android:layout_width="@dimen/carousel_item_width"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_marginRight="@dimen/carousel_item_margin_right"
    android:orientation="vertical">

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <ImageView
            android:id="@+id/imageCarousel"
            android:layout_width="match_parent"
            android:layout_height="@dimen/carousel_image_poster_height"

            />

        <TextView
            android:id="@+id/live"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="@dimen/carouse_item_live_margin_left"
            android:layout_marginTop="@dimen/carousel_item_live_margin_top"
            android:padding="@dimen/carousel_item_live_padding"
            android:textColor="@color/carousel_live_text"
            android:textSize="@dimen/carousel_item_live_text_size"
            android:textStyle="bold" />
    </RelativeLayout>

    <TextView
        android:id="@+id/titleCarousel"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:background="@color/carousel_content_title_background"
        android:gravity="center"
        android:padding="7dp"
        android:singleLine="true"
        android:textColor="@color/carousel_content_title_text"
        android:textSize="@dimen/carousel_title_size" />
</LinearLayout>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-12-14 14:57:00

将此创建为可绘制的

代码语言:javascript
运行
复制
<shape xmlns:android="http://schemas.android.com/apk/res/android"
           android:shape="rectangle">

  <stroke
      android:width="1dp"
      android:color="@color/miniBlack"
      android:dashGap="10px"
      android:dashWidth="10px"/>
</shape>

将其设置为布局的背景,给它一个2dp padding,这样stroke就不会覆盖内容

代码语言:javascript
运行
复制
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/itemCarouselContainer"
    android:layout_width="@dimen/carousel_item_width"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_marginRight="@dimen/carousel_item_margin_right"
    android:orientation="vertical"
    android:background="@drawable/myfile"
    android:paddings="2dp"
 >...
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41145497

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档