2016-12-14 5 views
0

borderLayoutにborderを設定する必要があります。linearLayoutの背景に境界線とパディング付きのdrawableを設定しようとしますが、これはlinearLayoutの内側に設定され、サイズ、イメージ、textViewを変更します。境界線を境界線の外側に設定する方法や、境界線を重ねる方法がありますか?レイアウトの外枠

マイコード:

<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> 
+0

** NO **。ビューの外側に**何も追加することはできません(コンテナのビューを追加しない限り)。可能であれば、あなたが探しているのが「パディング」です。 –

答えて

1

レイアウトの背景はそれを2dp paddingを与えるようにstrokeがコンテンツ

<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" 
>... 
を上書きしません、それを設定して描画可能

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

としてこれを作成します。

関連する問題