所以,我试图在TextView 周围环绕圆形ProgressBar。每当我这样做时,它会被切断(多少取决于设备),并且屏幕左侧和ProgressBar
之间也有一个荒谬的填充。
这就是我希望它的样子:
图像实际上是来自android工作室预览版(不知道它为什么在那里工作)
但由于某些原因,它看起来像这样(三星S8):
在OnePlus One上,它在右侧甚至更多的切断。
使用android:layout_marginleft="-xxdp"
我可以将切断部分从进度条移动到我想要的左边,但由于边距很大程度上取决于设备,我宁愿使用另一种方式(这也是不会恢复完整的进度条。)
这里是完整的xml代码:
<RelativeLayout
android:id="@+id/top_bar_relative_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="6"
android:background="@color/blue_top_bar">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ProgressBar
android:id="@+id/barTimer"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="85dp"
android:layout_height="85dp"
android:indeterminate="false"
android:max="500"
android:layout_alignParentLeft="true"
android:visibility="visible"
android:progress="500"
android:progressDrawable="@drawable/circle_progress_bar" />
<TextView
android:id="@+id/countdown_gameplay"
android:layout_width="wrap_content"
android:textStyle="bold"
android:layout_height="wrap_content"
android:text="5"
android:layout_centerInParent="true"
android:textColor="@color/white"
android:textSize="20sp" />
</RelativeLayout>
<View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_alignParentBottom="true"
android:background="@color/chicken_yellow" />
</RelativeLayout>
编辑:
刚刚发现它与这个java代码有关:
Animation an = new RotateAnimation(0.0f, 90.0f, 250f, 273f);
an.setFillAfter(true);
barTimer.startAnimation(an);
似乎rotateAnimation是问题的原因。任何人都知道如何更改它,所以它仍然可以将条形旋转90度,而不会切断并添加随机填充?
感谢任何帮助 TY
答案 0 :(得分:0)
尝试将此添加到RealtiveLayout
文件的XML
:
<ProgressBar
android:id="@+id/progressBar1"
android:indeterminate="true"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="87dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5 s"
android:id="@+id/txt_secondsleft"
android:layout_alignRight="@+id/progressBar1"
android:layout_alignLeft="@+id/progressBar1"
android:gravity="center"
android:layout_alignBottom="@+id/progressBar1"
android:layout_alignTop="@+id/progressBar1"
/>
希望它符合你的目的......