小编Shr*_*hat的帖子

如何保持textview低于进度条的进度?

如何设置 x 的位置,使其在所有屏幕中的进度条下方正确对齐?下面是我的活动类。我需要做哪些更改才能使代码正常工作?

public class ProgressBarAvtivity extends AppCompatActivity {
    ProgressBar progressBar;
    TextView tvProgress;
    int d = 60;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_progress_bar_avtivity);
        progressBar = ( ProgressBar ) findViewById(R.id.progressBar);
        progressBar.setProgress(d);
        tvProgress = ( TextView ) findViewById(R.id.tvProgress);
        tvProgress.setText(String.valueOf(d));
        tvProgress.setX();
    }
}
Run Code Online (Sandbox Code Playgroud)

下面是我的xml。请检查。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Activity.ProgressBarAvtivity">
    <ProgressBar
        android:id="@+id/progressBar"
        style="@android:style/Widget.ProgressBar.Horizontal"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_marginTop="10dp"
        android:padding="10dp"
        android:progressDrawable="@drawable/progreesbar" />
    <TextView
        android:id="@+id/tvProgress"
        android:layout_marginLeft="10dp"
        android:textSize="15sp"
        android:text="35"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

android

1
推荐指数
1
解决办法
417
查看次数

标签 统计

android ×1