自定义箭头没有图像:机器人自定义、箭头、机器人、图像

由网友(时光记得旧容颜.)分享简介:我跟着这个教程:http://looksok.word$p$pss.com/2013/08/24/android-triangle-arrow-defined-as-an-xml-shape/本教程是用于创建自定义箭头加/减键,而无需使用图像。箭头的形状是细然而向上箭头定位成其在按钮视图底部和向下箭头基部被定位成是碱在...

我跟着这个教程:http://looksok.word$p$pss.com/2013/08/24/android-triangle-arrow-defined-as-an-xml-shape/

本教程是用于创建自定义箭头加/减键,而无需使用图像。箭头的形状是细然而向上箭头定位成其在按钮视图底部和向下箭头基部被定位成是碱在按钮视图的顶部。在otherwords,箭头不正确对齐。

我想知道,是否有某种y轴的按键观点偏移,可以用来更好地定位箭头?在code我是:

 <的RelativeLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android    的xmlns:工具=htt​​p://schemas.android.com/tool​​s    机器人:layout_width =match_parent    机器人:layout_height =match_parent>    <按钮        机器人:ID =@ + ID / arrow_up        机器人:layout_width =75dp        机器人:layout_height =75dp        机器人:背景=@绘制/ custom_arrow/>    <按钮        机器人:ID =@ + ID / arrow_down        机器人:layout_width =75dp        机器人:layout_height =75dp        机器人:旋转=180        机器人:layout_toRightOf =@ ID / arrow_up        机器人:背景=@绘制/ custom_arrow/>< / RelativeLayout的> 

该custon_arrow.xml是:

 <?XML版本=1.0编码=UTF-8&GT?;<层列表的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>    <项目>        <  - 安卓!pivotX = -  40% - >        <旋转            机器人:fromDegrees =45            机器人:toDegrees =45            机器人:pivotX = -  20%            机器人:pivotY =88%>            <形状                机器人:形状=矩形>                <行程机器人:颜色=@色/透明的机器人:宽=5DP/>                [固体                    机器人:颜色=@色/ grey_shade/>            < /形状>        < /旋转>    < /项目>< /层列表> 

解决方案 左右箭头图标素材图片免费下载 高清图标素材png 千库网 图片编号923510

请您的 marginLeft 属性是一致的(一个是3DP另一种是5DP)。

SO! (以后看到图片)你在谈论的纵向对齐!

我觉得你可以轻松地添加一些paddingBottom会到向上的箭头,paddingTop的向下箭头。

OK,这是一个廉价和肮脏的伎俩,但...

...这个答案肯定是更好的:look

I followed this tutorial: http://looksok.wordpress.com/2013/08/24/android-triangle-arrow-defined-as-an-xml-shape/

The tutorial is for creating custom arrows as increment/decrement buttons without having to use images. The shape of the arrows are fine however the up arrow is positioned with its base at the bottom of the button view and the down arrow is positioned with is base at the top of the button view. In otherwords, the arrows are not aligned properly.

I was wondering, is there some sort of y-axis offset for button views that can be used to position the arrows better? The code I have is:

<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>

The custon_arrow.xml is:

<?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>

解决方案

Make your marginLeft attributes consistent (one is 3dp the other one is 5dp).

SO! (after seeing the picture) you were talking about vertical alignment!

I think you can easily add some paddingBottom to the up arrow and paddingTop to the down arrow.

OK, it's a cheap and dirty trick, but...

... this answer is surely better: look

阅读全文

相关推荐

最新文章