0

I am designing an ui with relative layout.I am using transparency for input boxes.But when I try to add a button,it is looking transparent.I don't know why.How can I resolve it ? Here screenshot:

enter image description here

This is my xml:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res/com.pack.x"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/login_background"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="115dp"
        android:layout_height="37.50dp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="28dp"
        android:src="@drawable/login_logo" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imageView1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="13dp"
        android:text="Anonim olarak konuşmaya başla"
        android:textColor="@color/white"
        android:textSize="18sp" />

    <View
        android:layout_width="88dp"
        android:layout_height="0.25dp"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/textView1"
        android:layout_marginLeft="43dp"
        android:layout_marginTop="26dp"
        android:background="#ffffff" />

    <TextView
        android:id="@+id/loginTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="19dp"
        android:text="login to app"
        android:textColor="@color/white"
        android:textSize="10sp" />

    <View
        android:layout_width="88dp"
        android:layout_height="0.25dp"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@+id/loginTitle"
        android:layout_marginTop="7dp"
        android:layout_marginRight="43dp"
        android:background="#ffffff" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="275dp"
        android:layout_height="35dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/loginTitle"
        android:alpha="0.62"
        android:background="@drawable/login_input"
        android:ems="10"
        android:hint="Username"
        android:paddingLeft="7.5dp"
        android:layout_marginTop="12.50dp"
        android:layout_marginLeft="43dp"
        android:textColor="@color/loginBox"
        android:textSize="12sp" />




    <EditText
        android:id="@+id/passwordBox"
        android:layout_width="275dp"
        android:layout_height="35dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/editText1"
        android:layout_marginLeft="43dp"
        android:layout_marginTop="6dp"
        android:alpha="0.62"
        android:background="@drawable/login_input"
        android:ems="10"
        android:hint="Password"
        android:paddingLeft="7.5dp"
        android:textColor="@color/loginBox"
        android:textSize="12sp" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/passwordBox"
        android:text="Button" />

</RelativeLayout>
Okan
  • 1,379
  • 3
  • 25
  • 38
  • Is the above screenshot from eclipse graphic view? I guess it should be fine when running the app in simulator or device. Just a tip: instead of setting the alpha to a view, set alpha to its background by photoshop or you can create drawable xml and set alpha to shape with radius to your desire. – Adil Soomro Jan 04 '15 at 18:15
  • No,it is running on simulator.Also eclipse graphic view looks same.For test I removed alpha attribute but button is still looks trasparent – Okan Jan 04 '15 at 18:17

4 Answers4

0

Your button is transparent (opacity is low) most likely default due to the theme of the project you have set it to.

You can change the transparency of any view in multiple ways. Go here and look at the multiple methods you can take.

How to Set Opacity (Alpha) for View in Android

Community
  • 1
  • 1
Tiensi
  • 227
  • 3
  • 11
0

Try this code snippet

button.getBackground().setAlpha(alphaValue);

Here range of alphaValue is between 0(fully transparent) to 255. Remove the transparent, try this

button.getBackground().setAlpha(255);
BeingMIAkashs
  • 1,375
  • 11
  • 18
  • I removed all alpha attribute but my button is still looking transparent. – Okan Jan 04 '15 at 18:32
  • I need to find problem source because not just button,everything looks transparent when I add a new item. – Okan Jan 04 '15 at 18:38
0

Could you set the background color for the button explicitly using android:background attribute ?

Zephyr
  • 6,123
  • 34
  • 33
0

May sound off topic but your 'button' is not aligned with 'Parent's Left' either. It may be that these two things are linked. Hope this helps!

Pranit Bankar
  • 453
  • 1
  • 7
  • 21