Java 进度条高度
我尝试在布局中集成进度条。进度条无法固定所有屏幕大小。我多次尝试调整高度。但没有人适合每种设备。因此,如何在所有屏幕大小中固定进度条的高度。Java 进度条高度,java,android,xml,layout,progress-bar,Java,Android,Xml,Layout,Progress Bar,我尝试在布局中集成进度条。进度条无法固定所有屏幕大小。我多次尝试调整高度。但没有人适合每种设备。因此,如何在所有屏幕大小中固定进度条的高度。 main.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-aut
main.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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/gray_bg"
android:orientation="vertical">
<ImageView
android:id="@+id/bg_pushup"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.7"
android:background="@android:color/background_dark"
android:src="@drawable/image_push_up"
android:visibility="gone" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/btn_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/counter_button_close" />
<ImageView
android:id="@+id/btn_sound"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/counter_button_mute" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/txt_start"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="START PUSH-UPS"
android:textColor="@android:color/background_light" />
<RelativeLayout
android:id="@+id/layout_pushup"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/txt_start"
android:layout_centerInParent="true"
android:src="@drawable/counter_bg"
android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:orientation="vertical">
<TextView
android:id="@+id/txt_pushup_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="0"
android:textAlignment="center"
android:textColor="@android:color/background_light"
android:textSize="36sp"
android:textStyle="bold" />
<TextView
android:id="@+id/txt_pushup_timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="false"
android:layout_centerVertical="false"
android:layout_gravity="center_horizontal"
android:text="0:00"
android:textAlignment="center"
android:textColor="#b5b4ad"
android:textSize="30sp" />
</LinearLayout>
<ProgressBar
android:id="@+id/progressBar2"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:max="100"
android:progress="75"
android:progressDrawable="@drawable/style_circular"
android:secondaryProgress="100" />
<TextView
android:id="@+id/textView19"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/progressBar2"
android:layout_alignBottom="@+id/progressBar2"
android:layout_centerHorizontal="true"
android:text="TextView"
android:textAlignment="center" />
<ImageView
android:id="@+id/img_shade"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView19"
android:layout_centerHorizontal="true"
android:layout_centerInParent="false"
android:layout_weight="0.05"
android:src="@drawable/counter_shade" />
<ImageView
android:id="@+id/btn_question_mark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/progressBar2"
android:layout_alignParentEnd="true"
android:layout_weight="1"
android:src="@drawable/question_mark" />
</RelativeLayout>
进度条
请帮助我为所有屏幕大小的设备设计xml。将进度条放入容器中,然后调整大小即可!像这样试试
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight = 1>
<ProgressBar
android:id="@+id/progressBar2"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:max="100"
android:progress="75"
android:progressDrawable="@drawable/style_circular"
android:secondaryProgress="100" />
</LinearLayout>
高度使用0dp并将重量赋予进度条如何!它会尽最大努力适应每一个屏幕尺寸,在哪里可以设置重量?我在进度条属性中找不到权重。请让我显示解决方案我的布局有许多项。进度条设置在布局的中心。因此,我无法为高度设置匹配\父级进度条位于布局之间!我想你可能在使用FrameLayout在布局上方显示它!请展示一些你的渲染屏幕,这样我就可以很容易地找到解决方案。我再贴一次照片。左上角和右上角具有图像视图。下面是文本视图。中心有进度条。两个文本视图位于进度条的中心。进度条下方有一个文本视图和两个图像视图。请提供您试图制作的设计的详细xml!bcz在这里,我可以从您的图片中看到,使用FrameLayout power很容易实现!我发布了我的xml,并清楚地更新了图片。