Java android Linearlayout set two colors - java

Hi I try do this I have a LinearLayout and how I can set two colors background inside a layout. I want to that half is a white and half is a black.
I tried this :
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false">
<layer-list>
<item>
<shape>
<corners android:radius="5dip"/>
<gradient
android:endColor="#fff"
android:startColor="#000" />
</shape>
</item>
</layer-list>
</item>
</selector>
This is my code from xml ;
<FrameLayout 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"
android:id="#+id/frame"
android:background="#color/background"
tools:context="pl.eltegps.smokkomunikator.ui.fragment.TopBarFragment">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/lin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/rel11"
android:layout_weight="0.5">
<ImageView
android:id="#+id/iv"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:src="#drawable/profil" />
<TextView
android:id="#+id/user"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/iv"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:clickable="true"
android:text="aaaaaaa"
android:textColor="#color/textColor" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/settings"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5">
<TextView
android:id="#+id/currentLocation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="left"
android:textColor="#fff" />
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:antialias="true"
android:background="#drawable/menu"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="11dp"
android:layout_marginEnd="11dp" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/lin"
>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:id="#+id/view"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_gravity="center"
android:background="#color/textColor" />
<LinearLayout
android:id="#+id/a"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="2sp"
android:layout_marginTop="2dp"
android:background="#drawable/dummy"
android:orientation="horizontal"
android:padding="5dp">
<RelativeLayout
android:id="#+id/serverStatusWrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:background="#drawable/shadow_green"
android:padding="2dp">
<ImageView
android:id="#+id/serverStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:antialias="true"
android:src="#drawable/ic_settings_input_antenna_white_24dp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/locationStatusWrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/shadow_red"
android:padding="2dp">
<ImageView
android:id="#+id/locationStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:antialias="true"
android:src="#drawable/ic_warning_white_24dp" />
</RelativeLayout>
</LinearLayout>
</FrameLayout>
</LinearLayout>
</RelativeLayout>
</FrameLayout>
dummy.xml :
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#ffffffff" />
<stroke
android:width="1dp"
android:color="#ff000000" />
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<corners
android:bottomLeftRadius="7dp"
android:bottomRightRadius="7dp"
android:topLeftRadius="7dp"
android:topRightRadius="7dp" />
</shape>
And I try do this : what is under the view I want to setbackground color black

Try
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle" >
<solid android:color="#ffffff" />
</shape>
</item>
<item>
<shape android:shape="rectangle" >
<solid android:color="#000000" />
</shape>
</item>
</layer-list>

Follow this steps :
Step 1: Create one background.xml file and put that file in drawable folder.
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:bottom="20dp">
<shape android:shape="rectangle" >
<size android:height="100dp" />
<solid android:color="#ffffff" />
</shape>
</item>
<item android:top="300dp">
<shape android:shape="rectangle" >
<size android:height="10dp" />
<solid android:color="#000000" />
</shape>
</item>
Step 2 : In your Main.xml layout file.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/keypad"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="#drawable/background">
Output :

Each ViewGroup can only have one background color, but you can easily achieve what you want by creating two ViewGroup elements.
Like.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#ff0000"/>
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#00ff00"/>

Related

How can I drop shadow background on Android?

I want to add a background behind the button. I want to create an opaque shape from white color for this background.. I did this with a gradient, but I couldn't. I want to create a soft shape.. I want a white shape like in the picture
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="270"
android:dither="false"
android:endColor="#FFFFFF"
android:startColor="#CCFFFFFF" />
<corners android:radius="5dp" />
</shape>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#drawable/drop_shadow" // here
android:paddingTop="16dp">
<TextView
android:id="#+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/green"
android:gravity="center"
android:text="#string/next"
android:textColor="#color/white"
android:textSize="22sp"
android:textStyle="bold" />
</RelativeLayout>
You should use a FrameLayout as root layout, and use an ImageView anchored to the bottom of the screen:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/id_framelayout"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".YourActivity">
<TextView
android:id="#+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/green"
android:gravity="center"
android:text="#string/next"
android:textColor="#color/white"
android:textSize="22sp"
android:textStyle="bold"
/>
<LinearLayout
android:orientation="vertical"
android:layout_gravity="bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatImageView
android:src="#drawable/shadow"
android:layout_width="match_parent"
android:layout_height="200dp"
/>
<FrameLayout
android:background="#color/white"
android:layout_width="match_parent"
android:layout_height="200dp">
< IF YOU WANT, YOU CAN INSERT HERE YOUR BUTTON >
</FrameLayout>
</LinearLayout>
</FrameLayout>
The shadow should be defined on res/drawable/shadow.xml as follows:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="-90"
android:endColor="#FFFFFF"
android:centerColor="#88FFFFFF"
android:startColor="#android:color/transparent"
android:type="linear">
</gradient>
</shape>

How to create corner radius in top left and bottom right in android?

How to create a corner radius in the top left and bottom right in android?
Like this
My code is
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#drawable/bg_layout">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:layout_margin="#dimen/twenty_sp"
android:text="#string/sign_in"
android:textColor="#color/colorWhite"
android:textSize="#dimen/thirty_sp" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bg_layout_white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/ten_sp"
android:orientation="vertical"
android:padding="#dimen/ten_sp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="#string/phone_number"
android:textColor="#color/colorBlack" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/five_sp"
android:orientation="horizontal">
<Spinner
android:id="#+id/main_spinner_coutry"
android:layout_width="wrap_content"
android:layout_height="#dimen/fifty_sp"
android:entries="#array/country_code"
android:prompt="#array/country_code"
android:spinnerMode="dropdown" />
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="#dimen/fifty_sp"
android:background="#drawable/bg_edt"
android:digits="0123456789"
android:ems="10"
android:hint="#string/_9876543210"
android:imeOptions="actionGo"
android:inputType="phone"
android:maxLength="10" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/ten_sp"
android:orientation="vertical"
android:padding="#dimen/ten_sp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="#string/password"
android:textColor="#color/colorBlack" />
<EditText
android:layout_width="match_parent"
android:layout_height="#dimen/fifty_sp"
android:layout_margin="#dimen/five_sp"
android:background="#drawable/bg_edt"
android:hint="#string/_9876543210"
android:inputType="textPassword" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/ten_sp"
android:orientation="vertical"
android:padding="#dimen/ten_sp">
<Button
android:id="#+id/main_btn_signin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bg_btn"
android:padding="#dimen/ten_sp"
android:text="#string/sign_in"
android:textAllCaps="false"
android:textColor="#color/colorWhite"
android:layout_margin="#dimen/ten_sp"/>
<TextView
android:layout_margin="#dimen/ten_sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="#dimen/ten_sp"
android:text="#string/forgot_password"
android:textColor="#color/colorAccent" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
Background drawable is
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle">
<solid android:color="#color/colorWhite" />
<corners
android:topRightRadius="30dp"
/>
</shape>
Show as the picture I want to top left corner and bottom right corner above code work but it show only one corner with background color, I try to create the above picture like but It can't work...
With the Material Components Library you can define custom CornerTreatment.
For example you can use a CardView and apply to it a ShapeAppearanceModel.
<LinearLayout
android:background="#color/colorPrimaryLight"
android:clipChildren="false"
android:clipToPadding="false"
..>
<com.google.android.material.card.MaterialCardView
android:id="#+id/card"
app:cardCornerRadius="32dp"
app:cardBackgroundColor="#color/colorPrimaryDark"
../>
</LinearLayout>
Then:
MaterialCardView cardView = findViewById(R.id.card);
cardView.setShapeAppearanceModel(cardView.getShapeAppearanceModel().toBuilder()
.setTopLeftCorner(new CrazyCornerTreatment())
.setBottomLeftCorner(CornerFamily.ROUNDED,0f)
.setBottomRightCorner(CornerFamily.ROUNDED,0f)
.build());
The top left corner can be defined with:
class CrazyCornerTreatment : CornerTreatment() {
override fun getCornerPath(
shapePath: ShapePath,
angle: Float,
interpolation: Float,
radius: Float
) {
val interpolatedRadius = radius * interpolation
shapePath.reset(0f, -radius * interpolation, 270f,270 -angle)
shapePath.addArc(
0f,
-2*interpolatedRadius,
2*interpolatedRadius,
0f,
180f,
- angle)
}
}
You would need to create a drawable shape
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#5089fa" />
<size
android:width="82dp"
android:height="82dp" />
<padding
android:bottom="10dp"
android:left="10dp"
android:right="10dp"
android:top="10dp" />
<corners
android:bottomLeftRadius="0dp"
android:bottomRightRadius="8dp"
android:topLeftRadius="8dp"
android:topRightRadius="0dp" />
Set that drawable shape as your background and it would result in something like:
Odd Rounded Corners
A drawable shape is a very good solution for this.
You could also slightly reframe it and use the bottom left corner of your top widget and the upper right of your 2nd widget.
If the background is white in the top and purple below that, you will get the desired result while using only the "normal" corner radius properties.
creating a background drawable with two colors i.e, white and purple
layout_background.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:bottom="300dp">
<shape android:shape="rectangle" >
<size android:height="300dp" />
<solid android:color="#ffffff" />
</shape>
</item>
<item android:top="300dp">
<shape android:shape="rectangle" >
<size android:height="50dp" />
<solid android:color="##2d39a1" />
</shape>
</item>
set this drawable as background for your layout
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/layout_background"
android:orientation="vertical"
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#drawable/purple_background">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:layout_margin="#dimen/twenty_sp"
android:text="#string/sign_in"
android:textColor="#color/colorWhite"
android:textSize="#dimen/thirty_sp" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/white_background"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/ten_sp"
android:orientation="vertical"
android:padding="#dimen/ten_sp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="#string/phone_number"
android:textColor="#color/colorBlack" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/five_sp"
android:orientation="horizontal">
<Spinner
android:id="#+id/main_spinner_coutry"
android:layout_width="wrap_content"
android:layout_height="#dimen/fifty_sp"
android:entries="#array/country_code"
android:prompt="#array/country_code"
android:spinnerMode="dropdown" />
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="#dimen/fifty_sp"
android:background="#drawable/bg_edt"
android:digits="0123456789"
android:ems="10"
android:hint="#string/_9876543210"
android:imeOptions="actionGo"
android:inputType="phone"
android:maxLength="10" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/ten_sp"
android:orientation="vertical"
android:padding="#dimen/ten_sp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="#string/password"
android:textColor="#color/colorBlack" />
<EditText
android:layout_width="match_parent"
android:layout_height="#dimen/fifty_sp"
android:layout_margin="#dimen/five_sp"
android:background="#drawable/bg_edt"
android:hint="#string/_9876543210"
android:inputType="textPassword" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/ten_sp"
android:orientation="vertical"
android:padding="#dimen/ten_sp">
<Button
android:id="#+id/main_btn_signin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bg_btn"
android:padding="#dimen/ten_sp"
android:text="#string/sign_in"
android:textAllCaps="false"
android:textColor="#color/colorWhite"
android:layout_margin="#dimen/ten_sp"/>
<TextView
android:layout_margin="#dimen/ten_sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="#dimen/ten_sp"
android:text="#string/forgot_password"
android:textColor="#color/colorAccent" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
purple_background.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle">
<solid android:color="#color/colorPurple" />
<corners
android:bottomLeftRadius="30dp"
/>
</shape>
white_background.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle">
<solid android:color="#color/colorWhite" />
<corners
android:topRightRadius="30dp"
/>
</shape>
adjust the height in the layout_background.xml file if the background doesn't fit. I hope you got it..

Drawing A Title Bar At The Top Of A CardView

I am trying to draw a title bar on the top of a card view.
This is what I am getting (Also why is the text "Test Title Goes Here" not being drawn?
but I am looking for this
This is the xml I am using to get this
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.v7.widget.CardView
android:id="#+id/card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:innerRadius="0dp"
android:shape="ring"
android:thicknessRatio="1.9"
app:cardCornerRadius="40dp"
app:contentPadding="13dp"
tools:layout_editor_absoluteY="35dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/header_when"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#D3D3D3"
android:textColor="#000000"
android:textStyle="bold"
android:padding="8dp"
tools:text="Test Title Goes Here" />
<com.google.android.flexbox.FlexboxLayout
android:id="#+id/layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:alignContent="stretch"
app:alignItems="stretch"
app:flexDirection="row"
app:flexWrap="wrap"
app:justifyContent="flex_start">
</com.google.android.flexbox.FlexboxLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</android.support.constraint.ConstraintLayout>
Any help is greatly appreciated
Passing a xml for your textview should help you. Add the xml as background for the textview in your main xml layout. In the custom textview xml do something like this:-
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#ffffffff"/>
<stroke android:width="3dp"
android:color="#ff000000" />
<padding android:left="1dp"
android:top="1dp"
android:right="1dp"
android:bottom="1dp" />
<corners android:bottomRightRadius="7dp"
android:bottomLeftRadius="7dp"
android:topLeftRadius="7dp"
android:topRightRadius="7dp" />
</shape>
I hope this helps.

Java Android create a view in FrameLayout

Hi I want to create a view which look like this :
But now I have this
and this is my xml code :
<?xml version="1.0" encoding="utf-8"?>
<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="pl..smok.ui.activity.SettingsActivity">
<FrameLayout
android:id="#+id/top_bar_container"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<LinearLayout
android:id="#+id/change_orieientation_screen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/top_bar_container"
android:layout_marginTop="10dp"
android:clickable="true">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Zmień orientację ekranu"
android:textSize="20dp" />
</RelativeLayout>
I don't know how I can create a line in center, and inline rectangle and a rectangle have two imageView.
Please look into this UI, I think it will be helpful for you
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="24dp"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_gravity="center"
android:background="#android:color/black" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/dummy"
android:layout_gravity="center"
android:padding="2dp"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:src="#mipmap/ic_launcher" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:src="#mipmap/ic_launcher" />
</LinearLayout>
</FrameLayout>
please add below code into drawable folder as a "dummy.xml"
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#ffffffff"/>
<stroke android:width="3dp"
android:color="#ff000000" />
<padding android:left="1dp"
android:top="1dp"
android:right="1dp"
android:bottom="1dp" />
<corners android:bottomRightRadius="7dp"
android:bottomLeftRadius="7dp"
android:topLeftRadius="7dp"
android:topRightRadius="7dp" />
</shape>

Edittext turns out to be black in color when I use special symbols like #

I have a little problem with my edittext fields, when you type in it, the whole field turns black when I type # . - or any other symble.
<TableRow
android:id="#+id/tableEmail"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:background="#drawable/cell_shape">
<TextView
android:id="#+id/textViewEmail"
android:layout_width="45dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:ems="10"
android:gravity="top"
android:text="#string/email"
android:textColor="#000000" />
<EditText
android:id="#+id/inputEmail"
android:layout_width="370dp"
android:layout_height="35dp"
android:background="#drawable/edit"
android:layout_marginBottom="2dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="10dp"
android:layout_marginTop="2dp"
android:layout_weight="1"
android:ems="10"
android:inputType="text" >
</EditText>
</TableRow>
I did try to chage the input type to textEmail, but it is the same.
My cell_shape looks like this
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape= "rectangle" >
<solid android:color="#fff"/>
<stroke android:width="1dp" android:color="#000"/>
</shape>
any ides?
edit
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<stroke
android:width="1dp"
android:color="#ffffff" />
</shape>

Categories

Resources