久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 Android Studio 中在 EditText 的所有四個邊上放置陰

Drop shadow around all the four sides of an EditText in Android Studio(在 Android Studio 中在 EditText 的所有四個邊上放置陰影)
本文介紹了在 Android Studio 中在 EditText 的所有四個邊上放置陰影的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

據我所知,沒有任何屬性可以在 EditText 字段周圍放置陰影,可以在布局文件中設置.我搜索了問題并找到了我必須提供自定義背景 xml drawable 的解決方案.

我的 drawable/background_with_shadow 看起來像這樣:

我正在為我的 LinearLayout 設置此屬性,其中包含一個 EditText

但是,它只會在底角和底角周圍投下陰影.我將如何處理所有四個邊和角?

我正在努力實現這一目標:

解決方案

有一些更好的方法可以在不使用 layer-list 的情況下在編輯文本周圍獲得陰影:

#1

將您的 EditText 包裝在 CardView 中,如下所示:

2

使用 9 補丁作為 EditText 的背景:

 <EditTextandroid:id=@+id/msg_box"安卓:填充=20dp";android:background=@dr??awable/shadow"android:layout_width=match_parent"android:layout_height="wrap_content";android:layout_centerVertical=真"安卓:線=5";安卓:重力=頂部";android:hint="輸入您的投訴..."android:textColorHint="#a7a7a7";android:textSize="15dp";/>

輸出

閱讀更多關于 9patch 這里.

這里是一個很棒的在線工具,可以生成 9 個補丁陰影.

As far as my knowledge aids me, there isn't any property to drop shadow around an EditText field, that can be set in the layout file. I searched for the problem and found solution that I've to provide a custom background xml drawable.

My drawable/background_with_shadow looks like this:

<?xml version="1.0" encoding="utf-8"?>
<layer-lis xmlns:android="http://schemas.android.com/apk/res/android">
    <item >
        <shape
            android:shape="rectangle">
            <solid android:color="@android:color/darker_gray" />
            <corners android:radius="5dp"/>
        </shape>
    </item>
    <item android:right="1dp" android:left="1dp" android:bottom="2dp">
        <shape
            android:shape="rectangle">
            <solid android:color="@android:color/white"/>
            <corners android:radius="5dp"/>
        </shape>
    </item>
</layer-list>

and I'm setting this property for my LinearLayout which contains an EditText

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background_with_shadow">
<EditText>
.
.
</EditText>
<LinearLayout>

However it just drops the shadow around the bottom and bottom corners. How would I do it for all the four sides and corners?

I'm trying to achieve this:

解決方案

There are some better ways to get shadow around your edit text without using layer-list :

#1

Wrap your EditText in a CardView like this :

<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:cardElevation="7dp"
    android:layout_margin="10dp"
    app:cardCornerRadius="0dp">

        <EditText
            android:id="@+id/msg_box"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:hint="Write a message"
            android:paddingLeft="5dp"
            android:paddingStart="5dp"
            android:textColorHint="#c7c7c7"
            android:textSize="15dp" />

</android.support.v7.widget.CardView>

OUTPUT :

2

Use a 9 patch as the background of your EditText :

    <EditText
        android:id="@+id/msg_box"
        android:padding="20dp"
        android:background="@drawable/shadow"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:lines="5"
        android:gravity="top"
        android:hint="Enter your complaint..."
        android:textColorHint="#a7a7a7"
        android:textSize="15dp" />

OUTPUT

Read more about 9patch here.

Here's a great online tool to generate 9 patch shadow.

這篇關于在 Android Studio 中在 EditText 的所有四個邊上放置陰影的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Cut, copy, paste in android(在android中剪切、復制、粘貼)
android EditText blends into background(android EditText 融入背景)
Change Line Color of EditText - Android(更改 EditText 的線條顏色 - Android)
EditText showing numbers with 2 decimals at all times(EditText 始終顯示帶 2 位小數的數字)
Changing where cursor starts in an expanded EditText(更改光標在展開的 EditText 中的開始位置)
EditText, adjustPan, ScrollView issue in android(android中的EditText,adjustPan,ScrollView問題)
主站蜘蛛池模板: 午夜久久久久久久久久一区二区 | 亚洲第一色站 | 国产精品久久久久久久久久免费看 | 日韩成人精品一区二区三区 | 国产欧美在线播放 | 成人国产网站 | 成人国产精品久久久 | jlzzjlzz国产精品久久 | 成人在线视频一区 | 日韩视频在线免费观看 | 中国一级特黄真人毛片 | 欧美一级在线观看 | 国产清纯白嫩初高生在线播放视频 | 久久一级大片 | 日韩欧美二区 | 在线观看免费国产 | 国产一区三区视频 | 亚洲www啪成人一区二区麻豆 | 午夜小视频免费观看 | 国产亚洲精品成人av久久ww | 久久国产精品视频免费看 | 亚洲综合中文字幕在线观看 | 国产91av视频在线观看 | 国产免费一级一级 | 四虎免费视频 | 久久一级大片 | 欧美日韩一区二区三区四区五区 | 黄色在线免费观看 | 亚洲一级淫片 | 国产精品久久福利 | 亚洲欧美在线一区 | 久久精品亚洲一区二区三区浴池 | 国产99久久精品一区二区永久免费 | 成人一级毛片 | 九九亚洲| 国产精品久久久久久婷婷天堂 | 亚洲欧美日韩国产综合 | 一级大黄色片 | 在线观看日本高清二区 | 免费一级黄色录像 | 人人做人人澡人人爽欧美 |