2014-02-14 43 views
0

我想让linearlayout的四角用this四舍五入来回答。因此,这里是我的shape.xml:在android中没有边框的形状

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="rectangle"> 
    <stroke android:width="2dp" android:color="#FFFFFFFF" /> 
    <gradient android:startColor="#ffc578" android:endColor="#fb9d23" 
       android:angle="225"/> 

    <corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp" 
      android:topLeftRadius="7dp" android:topRightRadius="7dp"/> 
</shape> 

但是这给了我黑色的丑陋一个border.It矩形形状看起来与一个美丽的背景图像的其他的LinearLayout里面太可怕了。我想摆脱那个黑色边框。我已经通过其他SO帖子和谷歌搜索,只是发现我可以使用图层来隐藏一些边界。是不是可以直接在上面的shape.xml中使用一些技巧?

编辑:

这里是我的布局main.xml中:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:orientation="vertical" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:background="@drawable/MovieHopBackground" 
       android:weightSum="12" 
     > 
    <ImageView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="3" 
      android:id="@+id/imageView"/> 
    <LinearLayout 
      android:orientation="horizontal" 
      android:layout_width="fill_parent" 
      android:layout_height="0" 
      android:layout_weight="2" 
      android:weightSum="4" 
      android:background="@drawable/shape"> 
     <RelativeLayout 
       android:orientation="horizontal" 
       android:layout_width="0" 
       android:layout_height="fill_parent" 
       android:layout_weight="3" 

       > 
      <EditText 
        android:layout_width="150dp" 
        android:layout_height="50dp" 
        android:background="@drawable/rounded_edittext" 
        android:id="@+id/editText" 
        android:layout_centerInParent="true" 
        /> 

     </RelativeLayout> 
     <RelativeLayout 
       android:orientation="horizontal" 
       android:layout_width="0" 
       android:layout_height="fill_parent" 
       android:layout_weight="1" 
       > 

     </RelativeLayout> 
    </LinearLayout> 

</LinearLayout> 

EDIT2: 下面是截图在IDE(裁剪):

enter image description here

+0

如果删除它,该怎么办? – Triode

+0

你想要一个带有圆角的图像背景吗? –

+0

@RajeshCP同样的结果。 – rahulserver

回答

0

试试这个

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 
    <solid android:color="#ffffff"/> 
    <corners android:radius="10dip"/> 
    <stroke android:color="#00000000" android:width="1dp"/> 

</shape> 
+0

无法工作!我可以从代码中说出来!尽管我已经测试过它。 – rahulserver

+0

你是否给了这段代码? – Hardik

+0

我完全用你的shape.xml替换了我的shape.xml。 #00000000是黑色的代码!你想达到什么目的? – rahulserver

0

首先
变化相对布局android:layout_width="0"android:layout_width=0dp

接下来
shape.xml

检查删除 <stroke android:width="2dp" android:color="#FFFFFFFF" />如果@drawable/MovieHopBackground有可能导致此问题的任何probs。我建议你看一下this

希望它有帮助!

+0

它似乎没有与shape.xml的问题。我用android:background =“#ffc578”替换了android:background =“@ drawable/shape”,但效果相同。就我所能猜测的那样,“@ drawable/MovieHopBackground”没有问题,因为它的显示像一个宝石。 – rahulserver

+0

请张贴问题的屏幕截图。对我来说帮助你更容易,因为现在我无法想象它! –

+0

请参阅edit2的图像 – rahulserver