【发布时间】:2019-03-08 15:29:52
【问题描述】:
mLayout:
列表视图
我想将 mChartView 设置为 match_parent(适合屏幕) 然后在 mChartView 下面添加 ListView 但这仅显示 mChartView
我尝试将固定大小设置为 mChartView 和 ListView 工作!但我无法将 mChartView 设置为适合其他屏幕尺寸。
我的 mChartView 和 ListView 使用 ScrollView
(下面的代码可以工作,但 mChart 不是 match_parent,因为大小固定)
<ScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/tv_units"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="30dp"
android:text="@string/label_data_baht"
android:textColor="@color/white"
android:textSize="16sp" />
<LinearLayout
android:id="@+id/ll_chart"
android:layout_width="match_parent"
android:layout_height="400dp" // fixed size
android:layout_margin="10dp"
android:orientation="vertical">
<com.github.mikephil.charting.charts.BarChart
android:id="@+id/mBarChart"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.github.mikephil.charting.charts.BarChart>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right">
<ImageView
android:layout_width="18dp"
android:layout_height="8dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="@drawable/bg_ic_saving" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tv_saving"
android:textColor="#ffffff"
android:textSize="13sp" />
<ImageView
android:layout_width="18dp"
android:layout_height="8dp"
android:layout_marginLeft="22dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="@drawable/bg_ic_expense"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="33dp"
android:text="@string/tv_expense"
android:textColor="#ffffff"
android:textSize="13sp" />
</LinearLayout>
</RelativeLayout>
<ListView
android:id="@+id/BillListYearly"
android:layout_width="match_parent"
android:layout_height="400dp" // fixed size
android:layout_marginTop="20dp"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:layout_gravity="center_horizontal"
android:focusable="false">
</ListView>
</LinearLayout>
</ScrollView>
谢谢。
(对不起,我的英语单词不完美)
【问题讨论】:
标签: java android android-layout layout screen