0

当我的布局添加scrollview时,我面临一个问题。当我将方向改为横向并滚动时,视图似乎重叠Portrait viewLandscape viewMPAndroidChart折线图scrollview重叠

以下是布局文件中的代码。任何一个人都可以帮我弄清楚为什么细节和图表过度分开?

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

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true"> 

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" 
     android:paddingBottom="@dimen/activity_vertical_margin" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:paddingTop="@dimen/activity_vertical_margin"> 

     <com.github.mikephil.charting.charts.LineChart 
      android:id="@+id/line_chart" 
      android:layout_width="match_parent" 
      android:layout_height="300dp"></com.github.mikephil.charting.charts.LineChart> 


     <android.support.v7.widget.GridLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      app:columnCount="2"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/symbol" 
       android:text="@string/detail_symbol" 
       app:layout_columnWeight="1" 
       app:layout_rowWeight="1" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/symbolValue" 
       app:layout_columnWeight="1" 
       app:layout_rowWeight="1" 
       tools:text="IBM" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/price" 
       android:text="@string/price" 
       app:layout_columnWeight="1" 
       app:layout_rowWeight="1" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/priceValue" 
       app:layout_columnWeight="1" 
       app:layout_rowWeight="1" 
       tools:text="Price" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/percentage_change" 
       android:text="@string/percentage_change" 
       app:layout_columnWeight="1" 
       app:layout_rowWeight="1" 
       tools:text="Percentage change" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/percentageChangeValue" 
       app:layout_columnWeight="1" 
       app:layout_rowWeight="1" 
       tools:text=".09%" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/absolute_change" 
       android:text="@string/absolute_change" 
       app:layout_columnWeight="1" 
       app:layout_rowWeight="1" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/absolutechangeValue" 
       app:layout_columnWeight="1" 
       app:layout_rowWeight="1" 
       tools:text="5.5" /> 

     </android.support.v7.widget.GridLayout> 

    </LinearLayout> 
</ScrollView> 

回答

0

试试这个

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true"> 

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:paddingBottom="@dimen/activity_vertical_margin" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:paddingTop="@dimen/activity_vertical_margin"> 

     <com.github.mikephil.charting.charts.LineChart 
      android:id="@+id/line_chart" 
      android:layout_width="match_parent" 
      android:layout_height="300dp"></com.github.mikephil.charting.charts.LineChart> 


     <android.support.v7.widget.GridLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      app:columnCount="2"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/symbol" 
       android:text="@string/detail_symbol" 
       app:layout_columnWeight="1" 
       app:layout_rowWeight="1" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/symbolValue" 
       app:layout_columnWeight="1" 
       app:layout_rowWeight="1" 
       tools:text="IBM" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/price" 
       android:text="@string/price" 
       app:layout_columnWeight="1" 
       app:layout_rowWeight="1" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/priceValue" 
       app:layout_columnWeight="1" 
       app:layout_rowWeight="1" 
       tools:text="Price" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/percentage_change" 
       android:text="@string/percentage_change" 
       app:layout_columnWeight="1" 
       app:layout_rowWeight="1" 
       tools:text="Percentage change" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/percentageChangeValue" 
       app:layout_columnWeight="1" 
       app:layout_rowWeight="1" 
       tools:text=".09%" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/absolute_change" 
       android:text="@string/absolute_change" 
       app:layout_columnWeight="1" 
       app:layout_rowWeight="1" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/absolutechangeValue" 
       app:layout_columnWeight="1" 
       app:layout_rowWeight="1" 
       tools:text="5.5" /> 

     </android.support.v7.widget.GridLayout> 

    </LinearLayout> 
</ScrollView> 
+0

不幸的是,这是行不通的。我在代码中看不到太多差异 – Spindoctor

+0

在LinearLayout中检查:android:layout_width =“match_parent” android:layout_height =“match_parent” –