在android布局中正确对齐页边距
下面是我的屏幕截图,其中包含一个进度条。从屏幕上可以看到,屏幕左右两侧与进度条之间的间距不相等。它不太靠右。如何使其与左侧相同,间隙更小 谢谢你的帮助 代码和屏幕截图如下:在android布局中正确对齐页边距,android,Android,下面是我的屏幕截图,其中包含一个进度条。从屏幕上可以看到,屏幕左右两侧与进度条之间的间距不相等。它不太靠右。如何使其与左侧相同,间隙更小 谢谢你的帮助 代码和屏幕截图如下: <?xml version="1.0" encoding="utf-8"?> <TableRow xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" an
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/blue"
android:textSize="18sp" />
<TextView
android:id="@+id/textLink"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:textSize="16sp" />
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="10dp"
android:progressDrawable="@drawable/green_progress_color" />
</LinearLayout>
</TableRow>
编辑
主布局
<?xml version="1.0" encoding="utf-8"?>
看起来您的“@drawable/green\u progress\u color”没有拉伸。尝试使用“@android:drawable/progress\u horizontal”检查这是否适用于您的布局或进度可绘制。不要像那样单独使用
表格行
,将其删除,只需使用线性布局即可。TableRow
导致问题<代码>表格行
必须始终嵌套在表格布局
()
我已将我的主布局作为编辑包含在内。您可以看到,我使用了表格布局
。在我的java代码中,在for循环中,我将行添加到表布局-TableRow convertView=(TableRow)LayoutInflater.from(this).inflate(R.layout.installing_adapter,null)
然后将行添加到tablelayout.addView(convertView)
@user264953这似乎是对TableLayout
的一种奇怪的使用-如果所有内容都在一个垂直列表中(您没有列),那么使用LinearLayout会更好。不管怎样,你能再发一次吗?看不到您的编辑。@user264953将您的父项表格布局
布局宽度
更改为匹配父项
。另外,作为旁注,TableRow
是一个LinearLayout
无论如何,因此您不需要在TableRows
@user264953下嵌套LinearLayout
,严重的是TableLayout
和TableRow
把它搞砸了。让您的顶部支架呈线性布局,然后您的孩子查看上面的xml,这样就可以了
<LinearLayout
android:id="@+id/bottom_layout_installing"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="@string/total_progress" />
<ProgressBar
android:id="@+id/total_installed_package_installer"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_margin="10dp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp" >
<Button
android:id="@+id/buttonAbort"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/button_bg"
android:onClick="onAbortClick"
android:text="@string/abort"
android:textColor="@android:color/white" />
<Button
android:id="@+id/buttonLaunch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/button_bg"
android:text="@string/install"
android:textColor="@android:color/white" />
</LinearLayout>
</LinearLayout>
<ScrollView
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_above="@id/bottom_layout_installing" >
<TableLayout
android:id="@+id/installingListview"
style="@android:color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:groupIndicator="@android:color/transparent"
android:listSelector="@android:color/transparent" >
</TableLayout>
</ScrollView>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/blue"
android:textSize="18sp" />
<TextView
android:id="@+id/textLink"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:textSize="16sp" />
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="10dp"
android:progressDrawable="@drawable/green_progress_color" />
</LinearLayout>