<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                使用drawable資源這方面是比較容易的,筆者學習并沒有花太多時間,但是卻是受益匪淺。 之前筆者在做圓角矩形的button的時候,還特意學了PS,想想當時真是天真,android是完全自帶這個功能的嘛。 當然android的強大也不僅于此,我們還可以修改seekbar的背景以及移動時的效果,還可以給textview、button等控件加邊框,還可以改變它們的形狀等等。 本篇文章就做了一個簡單的demo,便于大家理解drawable資源的使用: ![](https://box.kancloud.cn/2016-03-01_56d551efc9c0e.jpg) ??? ?![](https://box.kancloud.cn/2016-03-01_56d551eff4180.jpg) 在drawable中創建了比較多的xml文件,在layout中只有activity_main一個: ![](https://box.kancloud.cn/2016-03-01_56d551f023021.jpg) activity_main: ~~~ <?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" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin"> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@drawable/my_image" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@drawable/my_image" /> <SeekBar android:layout_width="match_parent" android:layout_height="100dp" android:max="100" android:progressDrawable="@drawable/my_bar" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/layout_logo" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/my_shape1" android:text="Hello World!" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/my_shape2" android:text="Hello World!" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/my_shape3" android:text="Hello World!" /> </LinearLayout> ~~~ my_image: ~~~ <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!--指定獲得焦點時的顏色--> <item android:state_focused="true" android:color="#f44"/> <!--指定失去焦點時的顏色--> <item android:state_focused="false" android:color="#ccf"/> </selector> ~~~ my_bar:(ic_launcher111和ic_launcher222只是兩個不一樣大的ic_launcher圖片) ~~~ <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <!--定義軌道背景--> <item android:id="@android:id/background" android:drawable="@drawable/ic_launcher111" /> <!--定義軌道上已完成部分的外觀--> <item android:id="@android:id/progress" android:drawable="@drawable/ic_launcher222" /> </layer-list> ~~~ layout_logo: ~~~ <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <!--定義三個層疊--> <item> <bitmap android:gravity="center" android:src="@mipmap/ic_launcher" /> </item> <item android:left="25dp" android:top="25dp"> <bitmap android:gravity="center" android:src="@mipmap/ic_launcher" /> </item> <item android:left="50dp" android:top="50dp" > <bitmap android:gravity="center" android:src="@mipmap/ic_launcher" /> </item> </layer-list> ~~~ my_shape1: ~~~ <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <!--設置填充顏色--> <solid android:color="#fff"/> <!--設置四周的內邊距--> <padding android:left="7dp" android:top="7dp" android:right="7dp" android:bottom="7dp"/> <!--設置邊框--> <stroke android:width="3dip" android:color="#ff0"/> </shape> ~~~ my_shape2: ~~~ <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <!--定義填充漸變顏色--> <gradient android:startColor="#FFFF0000" android:endColor="#80FF00FF" android:angle="45"/> <!--設置內填充--> <padding android:left="7dp" android:top="7dp" android:right="7dp" android:bottom="7dp"/> <!--設置圓角矩形--> <corners android:radius="8dp"/> </shape> ~~~ my_shape3: ~~~ <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <!--定義填充漸變顏色--> <gradient android:startColor="#ff0" android:endColor="#00f" android:angle="45"/> <!--設置內填充--> <padding android:left="7dp" android:top="7dp" android:right="7dp" android:bottom="7dp"/> <!--設置圓角矩形--> <corners android:radius="8dp"/> </shape> ~~~ 最后附上android studio源碼:[http://download.csdn.net/detail/double2hao/9324287](http://download.csdn.net/detail/double2hao/9324287)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看