2016-04-18 74 views
0

所以我一直在嘗試每種混合和搭配不同的佈局和設置,仍然無法弄清楚如何使這項工作。我想要在同一屏幕上有一個微調,就像MPAndroid折線圖一樣,我知道我可以手動修正高度並將其調整到合適的位置,但填寫父項或匹配父項不會考慮微調項,並將其從屏幕上推開!如果我用290dp的高度在我的手機上加載應用程序非常適合完美!加載它的7" 平板電腦並不是那麼漂亮......有一半的屏幕是空的。我怎麼含有圖表填補佔微調佈局?裹在圖表上的內容,使之無法使用。MPAndroid調整屏幕大小而沒有固定的高度

<?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> 

回答

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> 

由於使用重量,在任何屏幕上的「地圖和微調」將看起來像在相同的屏幕高度比例。

+0

android:layout_weight =「」這是一個很棒的工具!這將在未來爲我服務!謝謝! – Abstract3000

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> 
+0

感謝您的建議,我希望將底部的微調器,但我很欣賞輸入,我現在實際上看看代碼,只是爲了更好地瞭解它爲什麼工作:) – Abstract3000

+0

使微調器與底部對齊。只需將 'android:layout_alignParentBottom =「true」'添加到微調器中,然後將 'android:layout_above =「@ + id/spinner4」'添加到線圖。 來自@ User_1191的回答是使用linearlayout也是有效的。 –

相關問題