2016-08-02 80 views
0

我有一个Android的活动,我需要画一个黑色边框整个活动。我的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"> 

    <com.astuetz.PagerSlidingTabStrip 
     android:id="@+id/tabs" 
     android:layout_width="match_parent" 
     android:layout_height="60dp" 
     android:background="#33B5E5" 
     android:textColor="#FFFFFF" 
     /> 

    <android.support.v4.view.ViewPager 
     android:id="@+id/pager" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" /> 

</RelativeLayout> 

我该怎么做?

回答

2

您可以尝试在绘制文件夹中创建XML文件:

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> 
    <stroke android:color="@color/dark" android:width="2dp"/> 
</shape> 

并调用该文件作为android:background在你的根视图:

​​
+0

这个答案似乎是最简单的,因为它涉及透支最少。 – Shaishav

+0

我试了...但仍然没有工作 – Mark023

+0

也许需要填充设为您的根RelativeLayout的是可见的,因为你ViewPager是在上面,或者将机器人:背景,viewpager – Chol

1

做了一个背景<layer-list>绘制。在你的活动布局应用为android:background属性:

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
<item> 
    <shape 
     android:shape="rectangle"> 
     <solid android:color="#000000"/> 
    </shape> 
</item> 

<item 
    android:left="2dp" 
    android:right="2dp" 
    android:bottom="2dp" 
    android:top="2dp"> 
    <shape android:shape="rectangle"> 
     <solid android:color="#FFFFFF"/> 
    </shape> 
</item> 

+0

迪迪,你得到的答案 – DKV

0

您可以创建boder.xml文件夹drawble:

<stroke 
    android:width="1px" 
    android:color="@android:color/black" /> 

<solid android:color="@android:color/black" /> 

<padding 
    android:bottom="2dp" 
    android:left="2dp" 
    android:right="2dp" 
    android:top="2dp" /> 

然后,设置背景的RelativeLayout