1. 程式人生 > >xml設定圓角

xml設定圓角

在drawable資料夾下面新建text_view_border.xml
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"> <stroke android:width="1dp" android:color="@android:color/darker_gray" /> <solid android:color="@android:color/white"/> <corners android:radius="9dp" android:topLeftRadius="9dp" android:topRightRadius="9dp" android:bottomLeftRadius="9dp" android:bottomRightRadius="9dp"/><!-- 設定圓角半徑 --> </shape>
在佈局檔案呼叫:
<textview
    android:id="@+id/tv"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/text_view_border" />

在類檔案中呼叫:
tv.setbackgroundresource(r.drawable.text_view_border);

分析:
solid設定填充顏色,顏色值以#80開頭表示透明
stroke 設定邊框寬度,顏色值
corners設定圓角

相關推薦

xml設定圓角

在drawable資料夾下面新建text_view_border.xml<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/r

iOS之用xib給控制元件設定圓角、邊框效果

轉自:https://www.cnblogs.com/zhun/p/5616540.html   xib中為各種控制元件設定圓角 通過程式碼的方式設定 @interface ViewController () @property (weak, nonatomic)

style.xml 設定AppTheme

Android專案的 style.xml 設定AppTheme,以下是部分屬性詳解。 <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <!--狀態列顏色,應用的主要

筆記-iOS設定圓角方法以及指定位置設圓角

第一種方法:通過設定layer的屬性 程式碼: UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"TestImage"]]; // 只需設定layer層的兩個屬性 // 設定圓角 imageVi

Qt QDialog 設定圓角

對於普通的控制元件,我們通過樣式表(css)設定圓角就比較簡單 border-radius:5px 但是這個方法對於QDialog並沒有作用。經過仔細研究發現了。原來QDialog只是一個容器,對於已經設定無邊框(Qt::FramelessWindowHint)的對話方塊,直接設定border-radiu

AndroidStudio 如何設定圓角圖片

今天在做公司專案於的時候,要求做一個圓角圖片,一開始想法是在imgView設定一個背景弧度,後來發現有些不好,索性百度了下,百度上實現的方法有很多。我選擇用Glide的方式實現 貼一個Glide官方地址:Glide官方地址 不得不說,這個庫還是非常好用的,用來載入各種圖片也非常方面,強烈推薦

Android Dialog 設定圓角無效

這兩天有一個需求:設定dialog圓角,寫完後發現並沒有達到效果,以前也碰到這個問題,這裡記錄下解決方案,便於查閱。也有百度去查詢原因,卻沒有發現合適的解答,當然更可能是我沒找到,還是自己解決吧。 Dialog與DialogFragment 解決方案一致:只要設定背景透明解決問題了。 &

工具類(為控制元件設定圓角)

為了便於日常開發效率,因此建立了一些小的工具類便於使用. 具體 code 如下: 宣告: /* 為控制元件新增邊框樣式_工具類 */ #import <UIKit/UIKit.h> typedef NS_ENUM(NSInteger,LQQSideType

給ImageView動態設定圓角

現在需求就是在同一個ImageView上面有的顯示圓形圖示,有的顯示方形圖示,不能再xml佈局中寫成CircleImageView,所以就需要動態設定圓形: 導包:api 'com.github.bumptech.glide:glide:4.5.0' RequestOptions req

Android Button設定圓角和邊框

drawable右鍵新建Drawable resource file     設定圓角和邊框 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://sc

CSS學習——邊框設定圓角

邊框設定圓角 1.快速實現 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <t

mybatis-config.xml設定預設值配置

這個值太長了,特此記錄下 <properties>         <property name="username" value="root"/>       

open-data頭像設定圓角

<view class="userinfo">   <view class="userinfo-avatar">     <open-data  type="userAvatarUrl"></open-data>   </

ImageLoader設定圓角圖片

private ImageLoader instance; private DisplayImageOptions options; instance = ImageLoader.getInstance(); DisplayImageOptions options= new

Auto Layout 的元件該在何時設定圓角的 layer.cornerRadius

利用 UIView 的 layer.cornerRadius,我們可以設定元件的圓角,比方將正方形元件的 cornerRadius 設為它寬度的一半,將它變成圓形。然而當元件的大小由 Auto Layout 設定,隨著不同的 iPhone 尺寸改變大小時,我們就不能寫死 cornerRadius 了。我們必須

input設定圓角邊框去掉陰影

<div id="div" style=""> <input id="inputText" style="" /> <span type="button" id="btn" >查詢</span> </div>

android imageview 設定圓角

例圖:    接下來就看一下具體的程式碼:public class RoundAngleImageView extends ImageView { private Paint paint; /** * 個人理解是 * * 這兩個都

SliderLayout控制元件設定圓角圖片

一、概述 最近專案中要求給輪播圖設定圓角,該專案的輪播用的是daimajia的AndroidImageSlider控制元件,github連結為https://github.com/daimajia/AndroidImageSlider 用該控制元件

iOS給控制元件的指定位置設定圓角

在我們日常開發中,給一些控制元件設定圓角一般都是給四個角都設定圓角如下所示: searchBtn.layer.cornerRadius = 5.0f; //設定圓角的弧度 searchBtn.layer.masksToBounds = YES; 當

Android自定義TextView 自定義設定圓角背景色

public class RoundTextView extends TextView {  private int mBgColor = 0;  private int mCornerSize = 18; public RoundTextView(Context cont