gpt4 book ai didi

android - 更改 GradientDrawable 的填充

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:17:04 27 4
gpt4 key购买 nike

我有这个图层列表:

<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/outer_satop_btn">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:radius="5dp" />
<solid android:color="@android:color/transparent" />
</shape>
</item>
<item android:id="@+id/bottom_satop_btn">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:radius="5dp" />
<solid android:color="@color/satopButtonColor2" />
<padding
android:bottom="5dp" />
</shape>
</item>
<item android:id="@+id/top_satop_btn">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="@color/satopButtonColor" />
<corners android:radius="5dp" />
</shape>
</item>
</layer-list>

我想以编程方式更改 outer_satop_btn 的填充底部,但我没有找到这样做的任何东西:

LayerDrawable bgDrawable = (LayerDrawable)v.getBackground();
final GradientDrawable shape1 = (GradientDrawable) bgDrawable.findDrawableByLayerId(R.id.outer_satop_btn);
Rect padding = new Rect();
shape1.getPadding(padding);

我该怎么办?谢谢

最佳答案

您可以将其包装在 InsetDrawable 中: InsetDrawable(shape1, 0, 5, 0, 5)

关于android - 更改 GradientDrawable 的填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32823175/

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