2017-05-03 121 views
0

我已经创建了下面的登录活动是屏幕截图和代码 enter image description here如何使背景透明,改变我的活动设计

代码

<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" 
tools:context="pk.itbrowser.rehbar.LoginActivity" 
android:layout_marginTop="20sp" 
android:layout_marginRight="20sp" 
android:layout_marginLeft="20sp"> 
<LinearLayout 
    android:id="@+id/linearLayout" 
    android:background="@android:color/transparent" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:weightSum="10"> 
    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:layout_weight="1" 
     android:text="Login with Email" 
     android:textSize="20sp" 
     android:gravity="center"/> 
    <EditText 
     android:layout_marginTop="2sp" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:layout_weight="1" 
     android:background="@android:color/transparent" 
     android:hint="Email"/> 

    <EditText 
     android:layout_marginTop="2sp" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:layout_weight="1" 
     android:background="@android:color/transparent" 
     android:hint="Password" 
     android:inputType="textPassword"/> 
    <Button 
     android:layout_marginTop="5dp" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:layout_weight="1" 
     android:textColor="@color/white" 
     android:background="@color/colorAccent" 
     android:text="Login"/> 
    <Button 
     android:layout_marginTop="5dp" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:text="Need an Account?" 
     android:layout_weight="1"/> 
    <TextView 
     android:layout_marginTop="10sp" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="Forget Password?" 
     android:layout_centerInParent="true" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:gravity="center" /> 
</LinearLayout> 

现在我想改变此活动喜欢低于一个 lightText简单地想要建立这样的设计 enter image description here

+0

设置的背景是什么问题呢? –

+2

使用框架布局 – Krish

+0

设置ARGB颜色代码(#10000000)作为背景。 – Chetan

回答

0
  1. 套装transparent-black#D8000000)的背景颜色,您的容器RelativeLayout
  2. 设置dark-grey#3F4045)背景色为您EditText's

试试这个:

<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" 
tools:context="pk.itbrowser.rehbar.LoginActivity" 
android:layout_marginTop="20sp" 
android:layout_marginRight="20sp" 
android:layout_marginLeft="20sp" 
android:background="#D8000000"> <!-- Transparent-Black --> 

<LinearLayout 
    android:id="@+id/linearLayout" 
    android:background="@android:color/transparent" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:weightSum="10"> 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:layout_weight="1" 
     android:text="Login with Email" 
     android:textSize="20sp" 
     android:gravity="center"/> 

    <EditText 
     android:layout_marginTop="2sp" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:layout_weight="1" 
     android:background="#3F4045" 
     android:hint="Email"/> 

    <EditText 
     android:layout_marginTop="2sp" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:layout_weight="1" 
     android:background="#3F4045" 
     android:hint="Password" 
     android:inputType="textPassword"/> 

    <Button 
     android:layout_marginTop="5dp" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:layout_weight="1" 
     android:textColor="@color/white" 
     android:background="@color/colorAccent" 
     android:text="Login"/> 

    <Button 
     android:layout_marginTop="5dp" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:text="Need an Account?" 
     android:layout_weight="1"/> 

    <TextView 
     android:layout_marginTop="10sp" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="Forget Password?" 
     android:layout_centerInParent="true" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:gravity="center" /> 
</LinearLayout> 

希望这将帮助〜

+0

此代码不工作 –

+0

#Ferdous_Ahamed不工作 –

+0

帮我创建一个透明的活动 –

0

您需要声明透明主题活动在清单

android:theme="@android:style/Theme.Translucent" 

和布局的透明黑色

android:background="#44000000" 
+0

显示停止的错误 –