如何在视图中自定形状的位置? [英] How to position a custom shape inside a view?

查看:65
本文介绍了如何在视图中自定形状的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的定义水库自定义形状/绘制文件夹:

I've defined a custom shape in my res/drawable folder:

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line">
    <stroke
        android:color="#FF404040"
        android:width="1dp"
        android:dashGap="3dp"
        android:dashWidth="3dp"
    />
    <size
        android:height="1dp"
    />
</shape>

我用它作为我的观点一个背景。形状置于垂直居中的观点里面,但我希望它出现在视图,而不是底部,有没有办法做到这一点?

I'm using it as a background for one of my views. The shape is positioned vertically centered inside the view, but I want it to appear at the bottom of the view instead, is there a way to do this?

推荐答案

我不知道有一种方法做一个视图中的位置的形状。然而作为一种变通方法,我会考虑这样的事情。

I am not sure there is a way to do position shape inside a view. However as a workaround I would consider something like this.

<RelativeLayout >
    <OldView with shape as background now without any background
        android:layout_alignParentTop="true" android:layout_alignParentBottom="true"/>
    <View with this shape as background 
        android:layout_alignParentBottom="true"/>
</RelativeLayout>

这将假想给你你想要达到的目标。

This will supposedly give you what you want to achieve.

这篇关于如何在视图中自定形状的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆