Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 使用XML的箭头矩形形状大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
如何使用shape和xml实现这种形状的Departments标头而没有9-patch?

我的意思是左边带箭头的矩形.

android – 使用XML的箭头矩形形状

我的代码片段:

<layer-list xmlns:android="http://scheR_123_11845@as.android.com/apk/res/android">
    <item
        android:bottom="1px"
        android:left="@dimen/edittexT_Border"
        android:right="@dimen/edittexT_Border"
        android:top="@dimen/edittexT_Border">
        <shape android:shape="rectangle">
            <stroke
                android:width="@dimen/edittexT_Border_width"
                android:color="@color/menu_divider" />

            <solid android:color="@color/BACkground" />
            <corners android:radius="4dp" />


        </shape>
    </item>
</layer-list>

解决方法

如果您正在寻找这样的东西,请尝试以下代码..

android – 使用XML的箭头矩形形状

>在drawable文件夹中创建一个xml arrow_shape.

<?xml version="1.0" encoding="utf-8"?>
 <layer-list xmlns:android="http://scheR_123_11845@as.android.com/apk/res/android">   
 <item>
 <rotate android:fromdegrees="45" android:todegrees="45"  
   android:pivotX="-40%" android:pivotY="87%" >
    <shape android:shape="rectangle" >
        <stroke android:color="#c6802a" android:width="10dp"/>
        <solid android:color="#c6802a" />
    </shape>
</rotate>
</item>
</layer-list>

>在drawable文件夹中创建一个xml rectangle_shape.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://scheR_123_11845@as.android.com/apk/res/android" >
<item>
 <shape android:shape="rectangle">
    <solid android:color="#B2E3FA" />
 </shape>
</item>

>在主xml文件

<LinearLayout
xmlns:android="http://scheR_123_11845@as.android.com/apk/res/android"
xmlns:tools="http://scheR_123_11845@as.android.com/tools"
xmlns:app="http://scheR_123_11845@as.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center"
app:layouT_Behavior="@String/appbar_scrolling_view_behavior"
tools:context="com.example.stpl.myapplication.MainActivity">

<RelativeLayout
    android:id="@+id/arrow"
    android:layout_width="30dp"
    android:layout_height="30dp"
    android:BACkground="@drawable/arrow_shape"
    android:rotation="270" />

  <RelativeLayout
   android:id="@+id/rectangle"
   android:layout_width="150dp"
   android:layout_height="50dp"
   android:BACkground="@drawable/rectangle_shape"
   xmlns:android="http://scheR_123_11845@as.android.com/apk/res/android"
   xmlns:android="http://scheR_123_11845@as.android.com/tools" />

</LinearLayout>

大佬总结

以上是大佬教程为你收集整理的android – 使用XML的箭头矩形形状全部内容,希望文章能够帮你解决android – 使用XML的箭头矩形形状所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。