Android 在安卓系统中,线性布局已完全变为黑色
这个问题考验着我的耐心,我正在设计一个布局,这就是我迄今为止所达到的目标。查看下图 “保存”按钮上方的部分显示完整的黑色背景,带有货币和编辑文本 我实际上想做的是删除货币代码下面两个文本的下划线。我在这方面遵循了不同的建议,因此我将线性布局背景设置为Android 在安卓系统中,线性布局已完全变为黑色,android,xml,android-layout,Android,Xml,Android Layout,这个问题考验着我的耐心,我正在设计一个布局,这就是我迄今为止所达到的目标。查看下图 “保存”按钮上方的部分显示完整的黑色背景,带有货币和编辑文本 我实际上想做的是删除货币代码下面两个文本的下划线。我在这方面遵循了不同的建议,因此我将线性布局背景设置为#8000000。但下划线仍然在编辑框下面,它破坏了我的线性布局 因此,我决定删除它,并尝试其他东西。当我从任何地方删除那行代码并运行程序时。我的应用程序中仍然有黑色背景 下面是我的linearLayout的xml代码 <LinearLayo
#8000000
。但下划线仍然在编辑框下面,它破坏了我的线性布局
因此,我决定删除它,并尝试其他东西。当我从任何地方删除那行代码并运行程序时。我的应用程序中仍然有黑色背景
下面是我的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>
正如大家所看到的,我没有任何东西会在我的id布局1的线性布局中显示黑色
这是我得到的丑陋的屏幕布局
我这样问可能很愚蠢,但我的应用程序是否会存储某种缓存,因为它会显示相同的旧布局
提前谢谢
编辑
下面是布局的完整代码
<?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>
删除线性布局的背景 如果要删除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" />
android:background=“@null”
android:background=“@null”将删除编辑文本的下划线。我认为您之所以会出现黑屏,仅仅是因为自定义xml。我认为您没有问题,现在我不想删除下划线。我正在尝试删除linearlayout的黑色背景,因为删除了edittext下划线。这是我在drawable中定义的自定义xml,这就是顶部和底部的白色边框,它没有定义任何blackLet us。我认为这是因为主题的默认背景是黑色,尝试强制执行null
background@ChristopheCVB:您建议我在哪里更改默认背景主题?在邮件xml中?和我父母一起出去?黑色似乎是因为我在id为layout1I的子linearLayout中定义了自定义xml,我共享了自定义xml的代码。奇怪的是,当我将背景作为自定义xml删除时。黑色的部分消失了。但在我的自定义xml中似乎没有任何黑色声明
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/white
android:gravity="right"
android:text="USD"`enter code here`
android:textSize="30dp"
android:textColor="#ffffff"
android:textAllCaps="true"
android:textStyle="bold"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/white"
android:gravity="right"
android:text="0.00"
android:textSize="30dp"
android:textColor="#ffffff"
android:textAllCaps="true"
android:textStyle="bold"
/>