MPAndroid调整到没有固定高度的屏幕尺寸

时间:2016-04-18 05:18:33

标签: android xml layout mpandroidchart

所以我一直在尝试每种混合搭配不同的布局和设置,但仍然无法弄清楚如何使这项工作。我希望在同一屏幕上有一个微调器作为MPAndroid折线图,我知道我可以手动修复高度并调整它以使其适合,但是填充父母或匹配父母不考虑微调器并将其推离屏幕!如果我在手机上加载应用程序,高度为290dp非常适合!将它加载到7英寸平板电脑上并不那么漂亮......屏幕的一半是空的。如何包含图表来填充占据微调器的布局?图表上的换行内容使其无法使用。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".history"
    android:background="#303030">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
        <com.github.mikephil.charting.charts.LineChart
            android:id="@+id/chart"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"/>
</LinearLayout>

    <Spinner
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/spinner4"
    android:entries="@array/list3"
    android:popupBackground="#303030"
    android:layout_centerHorizontal="true" />

</LinearLayout>

2 个答案:

答案 0 :(得分:2)

尝试使用此功能我已删除了一些在我结束时遗漏的属性。这是微调器位于顶部的位置,其余部分用折线图填充。

<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout 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"
        android:background="#303030"
        android:orientation="vertical">

        <Spinner
            android:id="@+id/spinner4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:popupBackground="#303030" />

        <com.github.mikephil.charting.charts.LineChart
            android:id="@+id/chart"
            android:layout_width="fill_parent"
            android:layout_below="@+id/spinner4"
            android:layout_height="fill_parent" />


    </RelativeLayout>

答案 1 :(得分:1)

试试这个,

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout 
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 xmlns:tools="http://schemas.android.com/tools"
 tools:context=".history"
 android:background="#303030">

<LinearLayout
  android:layout_width="match_parent"
  android:layout_height="0dp"
  android:layout_weight="70">
    <com.github.mikephil.charting.charts.LineChart
        android:id="@+id/chart"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>
</LinearLayout>

<Spinner
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="30"
android:id="@+id/spinner4"
android:entries="@array/list3"
android:popupBackground="#303030"
android:layout_centerHorizontal="true" />


</LinearLayout>

由于在任何屏幕上使用重量&#34;地图和旋转器&#34;看起来会像屏幕高度相同。

相关问题