gpt4 book ai didi

android - 没有图像的自定义箭头 : Android

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:17:45 24 4
gpt4 key购买 nike

我遵循了本教程:http://looksok.wordpress.com/2013/08/24/android-triangle-arrow-defined-as-an-xml-shape/

本教程用于将自定义箭头创建为递增/递减按钮,而无需使用图像。箭头的形状很好,但是向上箭头的底部位于按钮 View 的底部,向下箭头的底部位于按钮 View 的顶部。换句话说,箭头没有正确对齐。

enter image description here

我想知道,按钮 View 是否有某种 y 轴偏移量可用于更好地定位箭头?我的代码是:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<Button
android:id="@+id/arrow_up"
android:layout_width="75dp"
android:layout_height="75dp"
android:background="@drawable/custom_arrow" />

<Button
android:id="@+id/arrow_down"
android:layout_width="75dp"
android:layout_height="75dp"
android:rotation="180"
android:layout_toRightOf="@id/arrow_up"
android:background="@drawable/custom_arrow" />
</RelativeLayout>

custon_arrow.xml 是:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<!-- android:pivotX="-40%" -->
<rotate
android:fromDegrees="45"
android:toDegrees="45"
android:pivotX="-20%"
android:pivotY="88%" >
<shape
android:shape="rectangle" >
<stroke android:color="@color/transparent" android:width="5dp"/>
<solid
android:color="@color/grey_shade" />
</shape>
</rotate>
</item>
</layer-list>

最佳答案

<TextView 
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="▲"/>

<TextView 
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="▼"/>

可以得到here更多选择。

关于android - 没有图像的自定义箭头 : Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20805826/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com