如何使布局的所有子视图调整大小/更改位置以使我的TableLayout填满屏幕?

时间:2016-08-17 00:57:09

标签: android android-layout android-tablelayout android-design-library android-fonts

它不一定要调整子视图的大小,它只是适合屏幕,不会隐藏布局中的一些视图而不会在屏幕上留下难看的空间。

fragment_timetable.xml:

<LinearLayout 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"
    tools:context=".timetable.TimetableFragment">

    <include layout="@layout/fragment_timetable_login" />

    <include layout="@layout/fragment_timetable_table" />
</LinearLayout>

fragment_timetable_table.xml(Github链接因为超出了字符数限制): https://github.com/gogobebe2/TheDayAhead/blob/master/app/src/main/res/layout/fragment_timetable_table.xml

以下是所有代码(可能不相关):https://github.com/gogobebe2/TheDayAhead

如您所见,TableLayout中的字体大小和所有其他子视图太大,无法放在屏幕上: As you can see, the font size and all other child views in the <code>TableLayout</code> are too big to fit on the screen

如果屏幕较大,则屏幕太小并且不会填满屏幕: And if the screen is bigger, it's too small and doesn't fill the screen

1 个答案:

答案 0 :(得分:0)

我明白了。我需要做的就是将DatePickerDialogdatePickerDialog = new DatePickerDialog(this, R.style.DialogTheme, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { //Magic happens here } }, nowYear, nowMonth, nowDay); datePickerDialog.show(); 添加到android:weightSum="11"并将<TableLayout >添加到每个android:layout_weight="1"