當前位置:首頁 » 安卓系統 » android輸入框圓角

android輸入框圓角

發布時間: 2022-12-17 09:04:22

㈠ android 圓角邊框 陰影邊框怎麼設置

所謂添加陰影,就是兩個畫布從重疊,上方的畫布小於下方的畫布,陰影顏色為下方的畫布的顏色。
item 中shape 的屬性 (rectangle:矩形;line:線性;oval:橢圓;ring:環形),默認為矩形
corners //設置圓角幅度,必須是在shape=rectangle的時候,corners才有效
<corners
Android:radius="dimension" //全部的圓角半徑
android:topLeftRadius="dimension" //左上角的圓角半徑
android:topRightRadius="dimension" //右上角的圓角半徑
android:bottomLeftRadius="dimension" //左下角的圓角半徑
android:bottomRightRadius="dimension" /> //右下角的圓角半徑
eg:<corners android:radius="10dp" />
solid用以指定內部填充色
e.g:<solid android:color="color" />
gradient //定義漸變色,可以定義兩色漸變和三色漸變,及漸變樣式
linear(線性漸變)、radial(放射性漸變)、sweep(掃描式漸變), 在構造放射性漸變時,要加上android:gradientRadius屬性(漸變半徑),即必須指定漸變半徑的大小才會起作用。
<gradient
android:type=["linear" | "radial" | "sweep"] //共有3中漸變類型
android:angle="integer" //漸變角度,必須為45的倍數,0為從左到右,90為從上到下
android:centerX="float" //漸變中心X的相當位置,范圍為0~1
android:centerY="float" //漸變中心Y的相當位置,范圍為0~1
android:startColor="color" //漸變開始點的顏色
android:centerColor="color" //漸變中間點的顏色,在開始與結束點之間
android:endColor="color" //漸變結束點的顏色
android:gradientRadius="float" //漸變的半徑,只有當漸變類型為radial時才有效
android:useLevel=["true" | "false"] /> //使用LevelListDrawable時就要設置為true。設為false時才有漸變效果
stroke //這是描邊屬性,可以定義描邊的寬度,顏色,虛實線等
<stroke
android:width="dimension" //描邊的寬度
android:color="color" //描邊的顏色 // 以下兩個屬性設置虛線
android:dashWidth="dimension" //虛線的寬度,值為0時是實線
android:dashGap="dimension" /> //虛線的間隔

㈡ Android如何設置圓角按鈕

可以通過shape設置圓角
<!-- 設置圓角 -->
<corners android:radius="2dp" >
</corners>
擴展:
<?xml version="1.0" encoding="utf-8"?>
<!-- shape如果不聲明形狀默認是正方形 -->
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- 設置填充色 -->

<solid android:color="#4285f4" >
</solid>
<!-- 設置邊框的顏色和寬度 -->
<stroke
android:width="1dp"
android:color="#4285f4" >
</stroke>
</shape>
通過selector設置點擊效果

button_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- 這個是用於控制按鈕組背景的文件 -->
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<!-- **點擊時效果**********背景引用的資源*************************是否獲得焦點*********************是否按下******* -->
<item android:drawable="@drawable/button_p" android:state_focused="true" android:state_pressed="false"/>
<item android:drawable="@drawable/button_p" android:state_focused="true" android:state_pressed="true"/>
<item android:drawable="@drawable/button_p" android:state_focused="false" android:state_pressed="true"/>

<!-- **************沒有任何操作時顯示的背景************** -->
<item android:drawable="@drawable/button_n"></item>
</selector>
在xml文件中設置button的background屬性。
android:background="@drawable/button_bg"

㈢ Android中使用CardView實現圓角對話框

前言:隨著用戶體驗的不斷的加深,良好的UI視覺效果也必不可少,以前方方正正的對話框樣式在APP已不復存在,取而代之的是帶有圓角效果的Dialog,之前設置對畫框的圓角效果都是通過drawable/shape屬性來完成,隨著Google API的不斷更新,API 21(Android 5.0)添加了新的控制項CardView,這使得圓角的實現更加方便快捷。

效果圖:

導入CardView依賴(API 21新控制項)

1.cardCornerRadius屬性:設置圓角的弧度大小,這里設置的為10dp

2.CardView還有padding、cardUseCompatPadding(內邊距)、background等屬性

3.CardView繼承自FrameLayout,使用時可以重新嵌套布局

使用的是V7包的AlertDialog實現的,當然也可以使用Dialog實現。

總結:CardView實現對話框的圓角效果更加的方便,不用編寫shape屬性設置背景,當標題欄需要背景色時,也無需考慮設置標題欄的shape背景(不使用CardView時,如果不使用shape設置背景色,會導致左上和右上不會變成圓角)。

㈣ android自定義對話框怎麼設置弧度

我想你想要實現圓角的對話框,可以參考如下:

package com.example.jjy.myapplication;
import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
/**
* Created by jjy on 16-5-15.
*/
public class MyDialog extends Dialog{
private Button positiveButton, negativeButton;
private TextView contenttv;

public MyDialog(Context context) {
super(context,R.style.mydialog);
View view = LayoutInflater.from(getContext()).inflate(R.layout.mydialoglayout, null); //通過LayoutInflater獲取布局
contenttv = (TextView) view.findViewById(R.id.title);
positiveButton = (Button) view.findViewById(R.id.acceptbtn);
negativeButton = (Button) view.findViewById(R.id.refusebtn);
setContentView(view); //設置view
}
//設置內容
public void setContent(String content) {
contenttv.setText(content);
}
//確定按鈕監聽
public void setOnPositiveListener(View.OnClickListener listener){
positiveButton.setOnClickListener(listener);
}

//否定按鈕監聽
public void setOnNegativeListener(View.OnClickListener listener){
negativeButton.setOnClickListener(listener);
}
}

R.style.mydialog 對話框屬性在 values/styles.xml中設置:

[html] view plain
<resources>
<style name="mydialog" parent="android:style/Theme.Dialog">
<!-- 背景透明 -->
<item name="android:windowBackground">@android:color/transparent</item>
<!-- 沒有標題 -->
<item name="android:windowNoTitle">true</item>
<!-- 背景模糊 -->
<item name="android:backgroundDimEnabled">true</item>
</style>
</resources>

㈤ 怎麼給android 邊框設置成圓角的

設置圓角的話,一般都是使用shape.xml添加到布局的頭部,就可以實現圓角,裡面可以控制角度

熱點內容
php緩存時間 發布:2025-03-23 15:34:52 瀏覽:11
安卓如何掃臉 發布:2025-03-23 15:32:56 瀏覽:354
安卓下載提示音在哪個文件夾 發布:2025-03-23 15:17:08 瀏覽:83
資料庫表中數據類型 發布:2025-03-23 15:16:14 瀏覽:582
如何讓其他人都能連上伺服器 發布:2025-03-23 15:01:34 瀏覽:44
androidbus 發布:2025-03-23 14:55:34 瀏覽:563
交叉編譯目錄 發布:2025-03-23 14:53:08 瀏覽:178
javaruby 發布:2025-03-23 14:44:59 瀏覽:914
哪些汽車配置了激光大燈 發布:2025-03-23 14:34:18 瀏覽:611
aiony怎麼選配置 發布:2025-03-23 14:32:36 瀏覽:294