gpt4 book ai didi

android:画圆切边框

转载 作者:太空狗 更新时间:2023-10-29 14:08:07 27 4
gpt4 key购买 nike

在项目 ListView 中,我想画一个圆圈,里面有特定的信息。但是圆形边框显示不正确。

这是我布局的一部分:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:azeoo="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="@dimen/schedule_workout_item_exercice_height"
android:gravity="center_vertical"
android:orientation="horizontal">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="@dimen/keyline_1"
android:orientation="horizontal">

<!-- Exercice number -->

<RelativeLayout
android:layout_width="24dp"
android:layout_height="24dp"
android:orientation="vertical">

<RelativeLayout
android:id="@+id/exercice_num_container"
android:visibility="visible"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/exercice_num"
style="@style/ItemExerciceNum"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical|center_horizontal"
android:text="1" />

THIS IS THE CIRCLE HERE:

<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/circle_exercice_num" />

</RelativeLayout>

</RelativeLayout>

<!-- Exercice informations -->

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="8dp">

...

可绘制的 circle_exercice_num.xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="0dp"
android:shape="ring"
android:thicknessRatio="1.9"
android:useLevel="false">
<solid android:color="@android:color/transparent"/>
<stroke
android:width="1dp"
android:color="@color/item_exercice_num"/>
</shape>

结果(即使在 Android Studio 的设计模式下!):

enter image description here

谢谢你们的帮助!

更新

好的,我找不到解决此 Android 问题的方法。所以,我拿了这个图书馆:https://github.com/pavlospt/CircleView .现在它工作得很好 :)

最佳答案

//edit code layout file

<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"
android:layout_gravity="center"
android:gravity="center"
tools:context=".MainActivity" >
<View
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@drawable/circleshape" />
</RelativeLayout>


//drawable folder xml file circleshape.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring"
android:thicknessRatio="1.9"
android:useLevel="false" >
<solid android:color="@android:color/transparent" />
<stroke
android:width="2dp"
android:color="@android:color/darker_gray" />
</shape>

关于android:画圆切边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31239297/

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