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

Android:創(chuàng)建一個(gè)圓形 TextView?

Android: Creating a Circular TextView?(Android:創(chuàng)建一個(gè)圓形 TextView?)
本文介紹了Android:創(chuàng)建一個(gè)圓形 TextView?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

下面是我當(dāng)前的簡(jiǎn)單 XML,但是我希望其中的 3 個(gè) TextView 是圓形的,而不是矩形的.

My current simple XML is below, however i would like the 3 TextViews within it to be circular, rather than rectangular.

如何更改我的代碼?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/tvSummary1"
        android:layout_width="270dp"
        android:layout_height="60dp" >
    </TextView>

    <TextView
        android:id="@+id/tvSummary2"
        android:layout_width="270dp"
        android:layout_height="60dp" >
    </TextView>

    <TextView
        android:id="@+id/tvSummary3"
        android:layout_width="270dp"
        android:layout_height="60dp" >
    </TextView>

</LinearLayout>

注意:我想要一個(gè)實(shí)際的圓形,而不是如下所示的彎曲邊緣矩形:

Note: I want an actual circle not the curved edge rectangle shown below:

當(dāng)前代碼:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/tvSummary1"
        android:layout_width="270dp"
        android:layout_height="60dp"
        android:text=" " 
        android:gravity="left|center_vertical"
        android:background="@drawable/circle"/>

    <TextView
        android:id="@+id/tvSummary2"
        android:layout_width="270dp"
        android:layout_height="60dp"
        android:background="@drawable/circle" >
    </TextView>

    <TextView
        android:id="@+id/tvSummary3"
        android:layout_width="270dp"
        android:layout_height="60dp"
        android:background="@drawable/circle" >
    </TextView>

</LinearLayout>

當(dāng)前輸出:

推薦答案

我也在尋找解決這個(gè)問(wèn)題的方法,我發(fā)現(xiàn)簡(jiǎn)單舒適的方法是將矩形 TextView 的形狀轉(zhuǎn)換為圓形.有了這個(gè)方法就完美了:

I was also looking for a solution to this problem and as easy and comfortable I found, was to convert the shape of a rectangular TextView to cirular. With this method will be perfect:

  1. 在名為circle.xml"的drawable文件夾中創(chuàng)建一個(gè)新的XML文件(例如)并用以下代碼填充它:

  1. Create a new XML file in the drawable folder called "circle.xml" (for example) and fill it with the following code:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">

    <solid android:color="#9FE554" />

    <size
        android:height="60dp"
        android:width="60dp" />

</shape>

使用此文件,您將創(chuàng)建 TextView 的新形式.在這種情況下,我創(chuàng)建了一個(gè)綠色圓圈.如果要添加邊框,則必須將以下代碼添加到上一個(gè)文件中:

With this file you will create the new form of TextView. In this case, I created a circle of green. If you want to add a border, you would have to add the following code to the previous file:

    <stroke
        android:width="2dp"
        android:color="#FFFFFF" />

  1. 使用以下代碼在可繪制文件夾中創(chuàng)建另一個(gè) XML 文件(rounded_textview.xml"):

  1. Create another XML file ( "rounded_textview.xml") in the drawable folder with the following code:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/circle" />
</selector>

這個(gè)文件將改變我們eligamos的TextView的方式.

This file will serve to change the way the TextView we eligamos.

  1. 最后,在我們想要更改方式的 TextView 屬性部分,我們前往背景"并選擇創(chuàng)建的第二個(gè) XML 文件(rounded_textview.xml").

  1. Finally, in the TextView properties we want to change the way section, we headed to the "background" and select the second XML file created ( "rounded_textview.xml").

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="H"
    android:textSize="30sp"
    android:background="@drawable/rounded_textview"
    android:textColor="@android:color/white"
    android:gravity="center"
    android:id="@+id/mark" />

通過(guò)這些步驟,TextView 不再是 TextView,而是矩形有一個(gè)圓形.只需更改形狀,而不是 TextView 的功能.結(jié)果如下:

With these steps, instead of having a TextView TextView rectagular have a circular. Just change the shape, not the functionality of the TextView. The result would be the following:

另外我不得不說(shuō),這些步驟可以應(yīng)用于在屬性中具有背景"選項(xiàng)的任何其他組件.

Also I have to say that these steps can be applied to any other component having the option to "background" in the properties.

好運(yùn)!!

這篇關(guān)于Android:創(chuàng)建一個(gè)圓形 TextView?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環(huán)繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動(dòng)生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數(shù)據(jù)庫(kù))
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對(duì)象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 亚洲天堂男人的天堂 | 久久精品a| 草比网站 | 午夜小视频在线播放 | 亚洲视频免费观看 | 国产精品一码二码三码在线 | 欧美日韩一 | 久久久久久久久久久久久久久久久久久久 | 国产精品久久久亚洲 | 国产精品欧美一区二区 | 自拍视频一区二区三区 | 一a级片 | 国产精品免费观看视频 | 久久精品色欧美aⅴ一区二区 | 手机av在线 | 一级片免费视频 | 网黄在线| 中文字幕一区二区三区在线观看 | 91中文字幕 | 中文字幕在线看第二 | 日韩一二三区 | 久久久精品一区二区三区四季av | 中文字幕一区二区三区乱码在线 | 精品一区二区不卡 | 午夜专区 | 国产精品久久久久久久久久 | 亚洲精品一区二区三区中文字幕 | 国产视频线观看永久免费 | 亚洲看片网站 | 久久网亚洲 | 久久久久国产一区二区三区 | 激情五月婷婷 | av毛片 | 高清免费在线 | 国产中文 | 亚洲高清久久 | 麻豆久久 | 99久久久无码国产精品 | 欧美三级成人理伦 | 久草欧美 | 成人精品毛片国产亚洲av十九禁 |