android:How to show drop shadow on an EditText view? The 2019 Stack Overflow Developer Survey Results Are InAndroid View shadowAdd drop shadow effects to EditText FieldStop EditText from gaining focus at Activity startupDownload a file with Android, and showing the progress in a ProgressDialogLimit text length of EditText in AndroidAllow multi-line in EditText view in Android?How to show soft-keyboard when edittext is focusedAndroid “Only the original thread that created a view hierarchy can touch its views.”Place cursor at the end of text in EditTextSet EditText cursor colorAndroid - tiled backgrounds occasionally get stretchedHow do I play an audio file in Android?
Multi tool use
Deal with toxic manager when you can't quit
Currents/voltages graph for an electrical circuit
What is the motivation for a law requiring 2 parties to consent for recording a conversation
Falsification in Math vs Science
Why isn't the black hole white?
Is bread bad for ducks?
Why “相同意思的词” is called “同义词” instead of "同意词"?
Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?
Loose spokes after only a few rides
Straighten subgroup lattice
Keeping a retro style to sci-fi spaceships?
Kerning for subscripts of sigma?
What to do when moving next to a bird sanctuary with a loosely-domesticated cat?
Old scifi movie from the 50s or 60s with men in solid red uniforms who interrogate a spy from the past
ODD NUMBER in Cognitive Linguistics of WILLIAM CROFT and D. ALAN CRUSE
Why not take a picture of a closer black hole?
Is it okay to consider publishing in my first year of PhD?
Mathematics of imaging the black hole
Why don't hard Brexiteers insist on a hard border to prevent illegal immigration after Brexit?
Can there be female White Walkers?
If I score a critical hit on an 18 or higher, what are my chances of getting a critical hit if I roll 3d20?
Why can't devices on different VLANs, but on the same subnet, communicate?
How can I define good in a religion that claims no moral authority?
Why was M87 targeted for the Event Horizon Telescope instead of Sagittarius A*?
android:How to show drop shadow on an EditText view?
The 2019 Stack Overflow Developer Survey Results Are InAndroid View shadowAdd drop shadow effects to EditText FieldStop EditText from gaining focus at Activity startupDownload a file with Android, and showing the progress in a ProgressDialogLimit text length of EditText in AndroidAllow multi-line in EditText view in Android?How to show soft-keyboard when edittext is focusedAndroid “Only the original thread that created a view hierarchy can touch its views.”Place cursor at the end of text in EditTextSet EditText cursor colorAndroid - tiled backgrounds occasionally get stretchedHow do I play an audio file in Android?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I apply elevation attribute and a drawable background which supply a rounded outline to the EditText View
, but there is no shadow as expected.
<?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"
android:layout_margin="20dp"
android:background="#FAFAFA"
tools:context=".MainActivity">
<EditText
android:id="@+id/editText"
android:layout_width="0dp"
android:layout_height="51dp"
android:layout_marginTop="52dp"
android:elevation="20dp"
android:background="@drawable/rounded_edittext"
android:drawableStart="@drawable/ic_search_icon"
android:drawableLeft="@drawable/ic_search_icon"
android:ems="10"
android:inputType="textPersonName"
android:paddingLeft="20dp"
android:paddingRight="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" />
</android.support.constraint.ConstraintLayout>
And the background rounded_edittext.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFFFFF"/>
<corners
android:bottomRightRadius="27.5dp"
android:bottomLeftRadius="27.5dp"
android:topLeftRadius="27.5dp"
android:topRightRadius="27.5dp"/>
<stroke android:color="#66000000" android:width="0.5dp"/>
</shape>
UPDATE
Below is the original design.
border color #000000 opacity 10(0~100)
shadow color #000000 opacity 5(0~100)
android
add a comment |
I apply elevation attribute and a drawable background which supply a rounded outline to the EditText View
, but there is no shadow as expected.
<?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"
android:layout_margin="20dp"
android:background="#FAFAFA"
tools:context=".MainActivity">
<EditText
android:id="@+id/editText"
android:layout_width="0dp"
android:layout_height="51dp"
android:layout_marginTop="52dp"
android:elevation="20dp"
android:background="@drawable/rounded_edittext"
android:drawableStart="@drawable/ic_search_icon"
android:drawableLeft="@drawable/ic_search_icon"
android:ems="10"
android:inputType="textPersonName"
android:paddingLeft="20dp"
android:paddingRight="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" />
</android.support.constraint.ConstraintLayout>
And the background rounded_edittext.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFFFFF"/>
<corners
android:bottomRightRadius="27.5dp"
android:bottomLeftRadius="27.5dp"
android:topLeftRadius="27.5dp"
android:topRightRadius="27.5dp"/>
<stroke android:color="#66000000" android:width="0.5dp"/>
</shape>
UPDATE
Below is the original design.
border color #000000 opacity 10(0~100)
shadow color #000000 opacity 5(0~100)
android
1
Possible duplicate of Add drop shadow effects to EditText Field
– sunil sunny
Mar 22 at 3:38
add a comment |
I apply elevation attribute and a drawable background which supply a rounded outline to the EditText View
, but there is no shadow as expected.
<?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"
android:layout_margin="20dp"
android:background="#FAFAFA"
tools:context=".MainActivity">
<EditText
android:id="@+id/editText"
android:layout_width="0dp"
android:layout_height="51dp"
android:layout_marginTop="52dp"
android:elevation="20dp"
android:background="@drawable/rounded_edittext"
android:drawableStart="@drawable/ic_search_icon"
android:drawableLeft="@drawable/ic_search_icon"
android:ems="10"
android:inputType="textPersonName"
android:paddingLeft="20dp"
android:paddingRight="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" />
</android.support.constraint.ConstraintLayout>
And the background rounded_edittext.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFFFFF"/>
<corners
android:bottomRightRadius="27.5dp"
android:bottomLeftRadius="27.5dp"
android:topLeftRadius="27.5dp"
android:topRightRadius="27.5dp"/>
<stroke android:color="#66000000" android:width="0.5dp"/>
</shape>
UPDATE
Below is the original design.
border color #000000 opacity 10(0~100)
shadow color #000000 opacity 5(0~100)
android
I apply elevation attribute and a drawable background which supply a rounded outline to the EditText View
, but there is no shadow as expected.
<?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"
android:layout_margin="20dp"
android:background="#FAFAFA"
tools:context=".MainActivity">
<EditText
android:id="@+id/editText"
android:layout_width="0dp"
android:layout_height="51dp"
android:layout_marginTop="52dp"
android:elevation="20dp"
android:background="@drawable/rounded_edittext"
android:drawableStart="@drawable/ic_search_icon"
android:drawableLeft="@drawable/ic_search_icon"
android:ems="10"
android:inputType="textPersonName"
android:paddingLeft="20dp"
android:paddingRight="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" />
</android.support.constraint.ConstraintLayout>
And the background rounded_edittext.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFFFFF"/>
<corners
android:bottomRightRadius="27.5dp"
android:bottomLeftRadius="27.5dp"
android:topLeftRadius="27.5dp"
android:topRightRadius="27.5dp"/>
<stroke android:color="#66000000" android:width="0.5dp"/>
</shape>
UPDATE
Below is the original design.
border color #000000 opacity 10(0~100)
shadow color #000000 opacity 5(0~100)
android
android
edited Mar 22 at 6:11
Dictator
asked Mar 22 at 2:57
DictatorDictator
235
235
1
Possible duplicate of Add drop shadow effects to EditText Field
– sunil sunny
Mar 22 at 3:38
add a comment |
1
Possible duplicate of Add drop shadow effects to EditText Field
– sunil sunny
Mar 22 at 3:38
1
1
Possible duplicate of Add drop shadow effects to EditText Field
– sunil sunny
Mar 22 at 3:38
Possible duplicate of Add drop shadow effects to EditText Field
– sunil sunny
Mar 22 at 3:38
add a comment |
2 Answers
2
active
oldest
votes
Replace your rounded_edittext.xml with the following code:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item >
<shape
android:shape="rectangle">
<solid android:color="@android:color/darker_gray" />
<corners android:radius="27.5dp"/>
</shape>
</item>
<item android:right="1dp" android:left="1dp" android:bottom="2dp">
<shape
android:shape="rectangle">
<solid android:color="#FFFFFF"/>
<corners
android:radius="27.5dp"/>
<stroke android:color="#66000000" android:width="0.5dp"/>
</shape>
</item>
Also, replace android:elevation="20dp"
from EditText with android:elevation="4dp"
add a comment |
Go here : Android View shadow
Or if you want to a put shadow under your view, add the following
In your Layout.xml
<View android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/dropshadow"/>
drawble/dropshadow.xml >
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="@android:color/transparent"
android:endColor="#88333333"
android:angle="90"/>
</shape>
In this case, you can't directly apply the gradient as a background. You need to add the gradient background as<item>
in<layer-list>
.
– Kavita_p
Mar 22 at 4:54
I'm not suggesting to put it as an EditText background, You have to add this in a <View>'s Background for some effect under the perticular view so... Also i'm not using multiple items so no need to put <item> and <layer-list>, try this code by putting in some xml file and use it first.
– MDB
Mar 22 at 5:07
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55292273%2fandroidhow-to-show-drop-shadow-on-an-edittext-view%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Replace your rounded_edittext.xml with the following code:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item >
<shape
android:shape="rectangle">
<solid android:color="@android:color/darker_gray" />
<corners android:radius="27.5dp"/>
</shape>
</item>
<item android:right="1dp" android:left="1dp" android:bottom="2dp">
<shape
android:shape="rectangle">
<solid android:color="#FFFFFF"/>
<corners
android:radius="27.5dp"/>
<stroke android:color="#66000000" android:width="0.5dp"/>
</shape>
</item>
Also, replace android:elevation="20dp"
from EditText with android:elevation="4dp"
add a comment |
Replace your rounded_edittext.xml with the following code:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item >
<shape
android:shape="rectangle">
<solid android:color="@android:color/darker_gray" />
<corners android:radius="27.5dp"/>
</shape>
</item>
<item android:right="1dp" android:left="1dp" android:bottom="2dp">
<shape
android:shape="rectangle">
<solid android:color="#FFFFFF"/>
<corners
android:radius="27.5dp"/>
<stroke android:color="#66000000" android:width="0.5dp"/>
</shape>
</item>
Also, replace android:elevation="20dp"
from EditText with android:elevation="4dp"
add a comment |
Replace your rounded_edittext.xml with the following code:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item >
<shape
android:shape="rectangle">
<solid android:color="@android:color/darker_gray" />
<corners android:radius="27.5dp"/>
</shape>
</item>
<item android:right="1dp" android:left="1dp" android:bottom="2dp">
<shape
android:shape="rectangle">
<solid android:color="#FFFFFF"/>
<corners
android:radius="27.5dp"/>
<stroke android:color="#66000000" android:width="0.5dp"/>
</shape>
</item>
Also, replace android:elevation="20dp"
from EditText with android:elevation="4dp"
Replace your rounded_edittext.xml with the following code:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item >
<shape
android:shape="rectangle">
<solid android:color="@android:color/darker_gray" />
<corners android:radius="27.5dp"/>
</shape>
</item>
<item android:right="1dp" android:left="1dp" android:bottom="2dp">
<shape
android:shape="rectangle">
<solid android:color="#FFFFFF"/>
<corners
android:radius="27.5dp"/>
<stroke android:color="#66000000" android:width="0.5dp"/>
</shape>
</item>
Also, replace android:elevation="20dp"
from EditText with android:elevation="4dp"
answered Mar 22 at 3:48
Kavita_pKavita_p
325111
325111
add a comment |
add a comment |
Go here : Android View shadow
Or if you want to a put shadow under your view, add the following
In your Layout.xml
<View android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/dropshadow"/>
drawble/dropshadow.xml >
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="@android:color/transparent"
android:endColor="#88333333"
android:angle="90"/>
</shape>
In this case, you can't directly apply the gradient as a background. You need to add the gradient background as<item>
in<layer-list>
.
– Kavita_p
Mar 22 at 4:54
I'm not suggesting to put it as an EditText background, You have to add this in a <View>'s Background for some effect under the perticular view so... Also i'm not using multiple items so no need to put <item> and <layer-list>, try this code by putting in some xml file and use it first.
– MDB
Mar 22 at 5:07
add a comment |
Go here : Android View shadow
Or if you want to a put shadow under your view, add the following
In your Layout.xml
<View android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/dropshadow"/>
drawble/dropshadow.xml >
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="@android:color/transparent"
android:endColor="#88333333"
android:angle="90"/>
</shape>
In this case, you can't directly apply the gradient as a background. You need to add the gradient background as<item>
in<layer-list>
.
– Kavita_p
Mar 22 at 4:54
I'm not suggesting to put it as an EditText background, You have to add this in a <View>'s Background for some effect under the perticular view so... Also i'm not using multiple items so no need to put <item> and <layer-list>, try this code by putting in some xml file and use it first.
– MDB
Mar 22 at 5:07
add a comment |
Go here : Android View shadow
Or if you want to a put shadow under your view, add the following
In your Layout.xml
<View android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/dropshadow"/>
drawble/dropshadow.xml >
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="@android:color/transparent"
android:endColor="#88333333"
android:angle="90"/>
</shape>
Go here : Android View shadow
Or if you want to a put shadow under your view, add the following
In your Layout.xml
<View android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/dropshadow"/>
drawble/dropshadow.xml >
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="@android:color/transparent"
android:endColor="#88333333"
android:angle="90"/>
</shape>
edited Mar 22 at 6:06
answered Mar 22 at 4:44
MDBMDB
668
668
In this case, you can't directly apply the gradient as a background. You need to add the gradient background as<item>
in<layer-list>
.
– Kavita_p
Mar 22 at 4:54
I'm not suggesting to put it as an EditText background, You have to add this in a <View>'s Background for some effect under the perticular view so... Also i'm not using multiple items so no need to put <item> and <layer-list>, try this code by putting in some xml file and use it first.
– MDB
Mar 22 at 5:07
add a comment |
In this case, you can't directly apply the gradient as a background. You need to add the gradient background as<item>
in<layer-list>
.
– Kavita_p
Mar 22 at 4:54
I'm not suggesting to put it as an EditText background, You have to add this in a <View>'s Background for some effect under the perticular view so... Also i'm not using multiple items so no need to put <item> and <layer-list>, try this code by putting in some xml file and use it first.
– MDB
Mar 22 at 5:07
In this case, you can't directly apply the gradient as a background. You need to add the gradient background as
<item>
in <layer-list>
.– Kavita_p
Mar 22 at 4:54
In this case, you can't directly apply the gradient as a background. You need to add the gradient background as
<item>
in <layer-list>
.– Kavita_p
Mar 22 at 4:54
I'm not suggesting to put it as an EditText background, You have to add this in a <View>'s Background for some effect under the perticular view so... Also i'm not using multiple items so no need to put <item> and <layer-list>, try this code by putting in some xml file and use it first.
– MDB
Mar 22 at 5:07
I'm not suggesting to put it as an EditText background, You have to add this in a <View>'s Background for some effect under the perticular view so... Also i'm not using multiple items so no need to put <item> and <layer-list>, try this code by putting in some xml file and use it first.
– MDB
Mar 22 at 5:07
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55292273%2fandroidhow-to-show-drop-shadow-on-an-edittext-view%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Vl 9hLNHKfiE3M7qfJNrCxnm Sv tX,h,Yf,v0Y AdHi h1omz7k66 us0 FUuTbBFHhqYNsoY5Ls fs8LEvJ
1
Possible duplicate of Add drop shadow effects to EditText Field
– sunil sunny
Mar 22 at 3:38