bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

如何使用Android實現圖片一邊的三角形邊框效果-創新互聯

這篇文章將為大家詳細講解有關如何使用Android實現圖片一邊的三角形邊框效果,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

成都創新互聯是一家從事企業網站建設、網站設計制作、成都做網站、行業門戶網站建設、網頁設計制作的專業的建站公司,擁有經驗豐富的網站建設工程師和網頁設計人員,具備各種規模與類型網站建設的實力,在網站建設領域樹立了自己獨特的設計風格。自公司成立以來曾獨立設計制作的站點上千家。

在真實的APP當中,我們還會加上一個SrcollView控件,這樣子才可以進行不斷地上下瀏覽。我們這里主要是為了讓大家明白這個視圖是該如何實現的,就不演示SrcollView控件下的做法了,直接在線性布局下做一個簡單的說明。由于在線性布局上面一共具有四張圖,因此咱們可以先單獨編寫每一個imageview的自定義view,然后<include>的語法將他們組合起來,這樣可以提高UI開發的效率,進行協同工作與開發。首先咱們先實現左上角和右上角的triangle view.

在build.gradle文件當中相應地方添加如下代碼,導入相應的maven庫:

allprojects {    repositories {      ...      maven { url "https://jitpack.io" }    }}

之后在另一個build.gradle文件當中添加庫:

dependencies {      implementation 'com.github.shts:TriangleLabelView:1.1.2'  }

咱們的前期工作就這樣做好啦,現在就開始正式編寫咱們的每一個三角形邊框視圖啦,首先是第一個位于左上角的視圖

一.card_left_top.xml:

<?xml version="1.0" encoding="utf-8"?><android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"  xmlns:app="http://schemas.android.com/apk/res-auto"  android:layout_width="match_parent"  android:layout_height="match_parent">  <RelativeLayout    android:layout_width="match_parent"    android:layout_height="match_parent">    <ImageView      android:id="@+id/image"      android:scaleType="centerCrop"      android:src="@drawable/s_image_2"      android:layout_width="match_parent"      android:layout_height="match_parent" />    <jp.shts.android.library.TriangleLabelView      android:layout_width="match_parent"      android:layout_height="match_parent"      android:layout_alignParentLeft="true"      android:layout_alignParentTop="true"      app:backgroundColor="@color/yellow_900"      app:corner="leftTop"      app:labelBottomPadding="5dp"      app:labelCenterPadding="0dp"      app:labelTopPadding="10dp"      app:primaryText="New"      app:primaryTextColor="@color/yellow_500"      app:primaryTextSize="16sp"      app:secondaryText="01"      app:secondaryTextColor="@color/yellow_100"      app:secondaryTextSize="11sp" />  </RelativeLayout></android.support.v7.widget.CardView>

編寫好后在preview當中顯示如下:

下面是位于右上角的視圖

二.card_right_top.xml:

<?xml version="1.0" encoding="utf-8"?><android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"  xmlns:app="http://schemas.android.com/apk/res-auto"  android:layout_width="match_parent"  android:layout_height="match_parent">  <RelativeLayout    android:layout_width="match_parent"    android:layout_height="match_parent">    <ImageView      android:id="@+id/image"      android:scaleType="centerCrop"      android:src="@drawable/s_image_4"      android:layout_width="match_parent"      android:layout_height="match_parent" />    <jp.shts.android.library.TriangleLabelView      android:layout_width="match_parent"      android:layout_height="match_parent"      android:layout_alignParentRight="true"      android:layout_alignParentTop="true"      app:backgroundColor="@color/teal_900"      app:corner="rightTop"      app:labelBottomPadding="5dp"      app:labelCenterPadding="0dp"      app:labelTopPadding="10dp"      app:primaryText="New"      app:primaryTextColor="@color/teal_500"      app:primaryTextSize="16sp"      app:secondaryText="01"      app:secondaryTextColor="@color/teal_100"      app:secondaryTextSize="11sp" />  </RelativeLayout></android.support.v7.widget.CardView>

三.card_right_buttom.xml:

<?xml version="1.0" encoding="utf-8"?><android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"  xmlns:app="http://schemas.android.com/apk/res-auto"  android:layout_width="match_parent"  android:layout_height="match_parent">  <RelativeLayout    android:layout_width="match_parent"    android:layout_height="match_parent">    <ImageView      android:id="@+id/image"      android:scaleType="centerCrop"      android:src="@drawable/s_image_3"      android:layout_width="match_parent"      android:layout_height="match_parent" />    <jp.shts.android.library.TriangleLabelView      android:layout_width="match_parent"      android:layout_height="match_parent"      android:layout_alignParentRight="true"      android:layout_alignParentBottom="true"      app:backgroundColor="@color/pink_900"      app:corner="rightBottom"      app:labelTopPadding="10dp"      app:labelCenterPadding="5dp"      app:labelBottomPadding="0dp"      app:primaryText="New"      app:primaryTextColor="@color/pink_500"      app:primaryTextSize="16sp"      app:secondaryText="01"      app:secondaryTextColor="@color/pink_100"      app:secondaryTextSize="11sp" />  </RelativeLayout></android.support.v7.widget.CardView>

四.card_left_buttom.xml:

<?xml version="1.0" encoding="utf-8"?><android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"  xmlns:app="http://schemas.android.com/apk/res-auto"  android:layout_width="match_parent"  android:layout_height="match_parent">  <RelativeLayout    android:layout_width="match_parent"    android:layout_height="match_parent">    <ImageView      android:id="@+id/image"      android:src="@drawable/s_image_1"      android:scaleType="centerCrop"      android:layout_width="match_parent"      android:layout_height="match_parent" />    <jp.shts.android.library.TriangleLabelView      android:layout_width="match_parent"      android:layout_height="match_parent"      android:layout_alignParentLeft="true"      android:layout_alignParentBottom="true"      app:backgroundColor="@color/blue_900"      app:corner="leftBottom"      app:labelTopPadding="10dp"      app:labelCenterPadding="5dp"      app:labelBottomPadding="0dp"      app:primaryText="New"      app:primaryTextColor="@color/blue_500"      app:primaryTextSize="16sp"      app:secondaryText="01"      app:secondaryTextColor="@color/blue_100"      app:secondaryTextSize="11sp" />  </RelativeLayout>

最后咱們整合一下就OK啦!整合后的主活動的代碼為:

五.activity_main.xml:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  xmlns:tools="http://schemas.android.com/tools"  xmlns:app="http://schemas.android.com/apk/res-auto"  android:layout_width="match_parent"  android:layout_height="match_parent"  android:orientation="vertical"  tools:context=".Fragment2"> <LinearLayout    android:layout_width="match_parent"    android:layout_height="0dp"    android:layout_weight="1"    android:orientation="horizontal">    <include android:layout_width="0dp"      android:layout_height="match_parent"      android:layout_weight="1"      android:layout_margin="2dp"      android:id="@+id/left_top" layout="@layout/card_left_top" />    <include android:layout_width="0dp"      android:layout_height="match_parent"      android:layout_weight="1"      android:layout_margin="2dp"      android:id="@+id/right_top" layout="@layout/card_right_top" />  </LinearLayout>  <LinearLayout    android:layout_width="match_parent"    android:layout_height="0dp"    android:layout_weight="1"    android:orientation="horizontal">    <include android:layout_width="0dp"      android:layout_height="match_parent"      android:layout_weight="1"      android:layout_margin="2dp"      android:id="@+id/left_bottom" layout="@layout/card_left_bottom" />    <include android:layout_width="0dp"      android:layout_height="match_parent"      android:layout_weight="1"      android:layout_margin="2dp"      android:id="@+id/right_bottom" layout="@layout/card_right_bottom" />  </LinearLayout></LinearLayout>

關于“如何使用Android實現圖片一邊的三角形邊框效果”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。

分享名稱:如何使用Android實現圖片一邊的三角形邊框效果-創新互聯
鏈接地址:http://vcdvsql.cn/article18/iedgp.html

成都網站建設公司_創新互聯,為您提供品牌網站設計自適應網站電子商務外貿網站建設移動網站建設標簽優化

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

成都網站建設公司