2016-03-06 79 views
0

这个问题正在测试我的耐心,我正在设计一个布局,这是我到目前为止所到之处。检查下面的图像LinearLayout已成为完全黑色android

enter image description here

上面的“保存”按钮的部分显示了一个完整的黑色背景下,一个与货币和EditText上。

我实际上想要做的是删除货币代码下面的两个EditText的下划线。我在这个thread上遵循不同的建议,因此我将linearLayout背景设置为#80000000。但下划线仍然在EditBox下面,它破坏了我的线性布局。

因此,我决定删除它,并尝试其他的东西。当我从任何地方移除该行代码并运行该程序时。我仍然在我的应用程序中获得黑色背景。

这里是我的LinearLayout的XML代码

<LinearLayout 
     android:id="@+id/layout1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:layout_weight="2" 
     android:paddingTop="10dp" 
     android:layout_marginBottom="30dp" 
     android:background="@drawable/custom_border" 
     > 
     <!--This layout is for typing currency values--> 
     <!--Creating two more sub linearLayout, to seperate two sections of 
     lef currency and right currency 
     android:background="@drawable/border_inner_linear" 
     --> 
     <LinearLayout 
      android:id="@+id/leftCurrencySection" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="left" 
      android:layout_weight="1" 
      android:orientation="vertical" 

      > 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="GBP" 
       android:textSize="30dp" 
       android:textColor="#ffffff" 
       android:textAllCaps="true" 
       android:textStyle="bold" 
       /> 

      <EditText 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="0.00" 
       android:textSize="30dp" 
       android:textColor="#ffffff" 
       android:textAllCaps="true" 
       android:textStyle="bold" 

       /> 

     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/rightCurrencySection" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="right" 
      android:layout_weight="1" 
      android:orientation="vertical"> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="right" 
       android:text="USD" 
       android:textSize="30dp" 
       android:textColor="#ffffff" 
       android:textAllCaps="true" 
       android:textStyle="bold" 
       /> 

      <EditText 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="right" 
       android:text="0.00" 
       android:textSize="30dp" 
       android:textColor="#ffffff" 
       android:textAllCaps="true" 
       android:textStyle="bold" 

       /> 

     </LinearLayout> 

    </LinearLayout> 

正如人们所看到的,我没有任何应显示在我的LinearLayout id为布局1黑色

这里是丑屏幕布局我越来越

enter image description here

这可能是愚蠢的我的要求,但确实我的应用程序将保存某种形式的缓存,因为...其中的旧版面显示相同吗?提前

感谢

编辑

这里是布局的完整代码

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:background="@drawable/layer_list" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:showIn="@layout/activity_main" 
    tools:context=".MainActivity" 
    android:orientation="vertical" 
    android:weightSum="5" 
    > 

    <LinearLayout 
     android:id="@+id/layout1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:layout_weight="2" 
     android:paddingTop="10dp" 
     android:layout_marginBottom="30dp" 
     android:background="@drawable/custom_border" 
     > 
     <!--This layout is for typing currency values--> 
     <!--Creating two more sub linearLayout, to seperate two sections of 
     lef currency and right currency 
     android:background="@drawable/border_inner_linear" 
     --> 
     <LinearLayout 
      android:id="@+id/leftCurrencySection" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="left" 
      android:layout_weight="1" 
      android:orientation="vertical" 

      > 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="GBP" 
       android:textSize="30dp" 
       android:textColor="#ffffff" 
       android:textAllCaps="true" 
       android:textStyle="bold" 
       /> 

      <EditText 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="0.00" 
       android:textSize="30dp" 
       android:textColor="#ffffff" 
       android:textAllCaps="true" 
       android:textStyle="bold" 
       android:background="@null" 
       /> 

     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/rightCurrencySection" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="right" 
      android:layout_weight="1" 
      android:orientation="vertical"> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="right" 
       android:text="USD" 
       android:textSize="30dp" 
       android:textColor="#ffffff" 
       android:textAllCaps="true" 
       android:textStyle="bold" 
       /> 

      <EditText 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="right" 
       android:text="0.00" 
       android:textSize="30dp" 
       android:textColor="#ffffff" 
       android:textAllCaps="true" 
       android:textStyle="bold" 
       android:background="@null" 
       /> 

     </LinearLayout> 

    </LinearLayout> 
    <!--End of This layout is for typing currency values--> 

    <LinearLayout 
     android:id="@+id/buttonSection" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:layout_weight="1" 
     > 
     <!--This layout is for save and change currency buttons--> 
      <Button 
       android:id="@+id/saveButton" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="Save"/> 

       <Button 
        android:id="@+id/currencyButton" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="Save"/> 
    </LinearLayout> 
    <!--End of save and change currency buttons--> 

    <!--Begin Layout for calculator begin--> 

    <GridLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:columnCount="3" 
     android:layout_gravity="center" 
     android:orientation="horizontal" 
     android:layout_weight="1" 
     > 


     <Button android:text="1" 
      android:background="@null" 
      /> 

     <Button android:text="2" /> 

     <Button android:text="3" /> 



     <Button android:text="4" /> 

     <Button android:text="5" /> 

     <Button android:text="6" /> 



     <Button android:text="7" /> 

     <Button android:text="8" /> 

     <Button android:text="9" /> 


     <Button android:text="." /> 

     <Button android:text="0" /> 

     <Button android:text="Del" /> 


    </GridLayout> 
    <!--End Layout for calculator--> 
    <!--End Layout for calculator End--> 


</LinearLayout> 

编辑:自定义XML

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:left="-10dp" android:right="-10dp" android:top="0dp" 
     android:bottom="0dp"> 
     <shape android:shape="rectangle"> 
      <stroke android:width="3dp" android:color="#faf8f8" /> 
     </shape> 
    </item> 
</layer-list> 
+0

我认为这是因为该主题的默认背景是黑色,尝试强制'null'背景 – ChristopheCVB

+0

@ChristopheCVB:你在哪里建议我改变默认背景主题?在邮件XML?与我的父母LinearLayout?它看起来是黑色的,因为我已经在id layout1 –

回答

0

代码删除线性布局的背景。

如果您想删除edittext中的下划线,则将该edittext的背景设置为null。

android:background="@null" 

<EditText 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@null" 
    android:gravity="right" 
    android:text="0.00" 
    android:textSize="30dp" 
    android:textColor="#ffffff" 
    android:textAllCaps="true" 
    android:textStyle="bold" /> 
+0

的子linearLayout中定义了自定义xml我认为你没有得到这个问题,现在我不想删除下划线。我试图删除linearlayout因删除edittext而产生的黑色背景下划线 –

+0

这是我在我的drawable中定义的自定义xml,这就是顶部和底部的白色边框,它没有定义任何黑色 –

+0

ok ..让我再看看.. –

0

android:background =“@ null”将删除编辑文本的下划线。我认为你只是因为自定义xml而变黑。你可以分享这个自定义的XML也可以解决这个问题。

+0

我已经分享了自定义xml的代码。奇怪,当我删除背景作为自定义XML。黑色部分消失了。但是在我的自定义xml中似乎没有任何黑色的声明 –