2016-12-12 6 views
0

ボタンとアンドロイドプロットを一緒にスクロールビューに入れて、スクロールしてボタンを見ることができないようにしました。私はandroidplot 0.9.8を使用しています。ボタンとアンドロイドプロットをスクロールビューに追加する

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:ap="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="example.example.MainActivity"> 
    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fillViewport="true"> 
     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/plotLayout"> 
      <com.androidplot.xy.XYPlot 
        android:id="@+id/plot" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        ap:Label="test" 
        ap:domainLabel="test" 
        ap:rangeLabel="test" 
        ap:renderMode="use_main_thread"/> 
      <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="horizontal" 
        android:layout_below="@id/plot"> 
        <Button 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:layout_weight="1" 
         android:text="test"/> 
        <Button 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:layout_weight="1" 
         android:text="test"/> 
        </LinearLayout> 
     </RelativeLayout> 
</ScrollView> 

EDIT:それは私が(androidplotのための一定の高さを指定するときことが思わ例えばアンドロイド:= "600dp" の代わりにアンドロイドのlayout_height:layout_height =ここ

は私のxmlファイルであります"match_parent")それはうまくスクロールします。 match_parentを使用するとスクロールできないのはなぜですか?

+0

あなたはRelativeViewが正しく閉じられていません –

+0

、申し訳ありません。まだ同じ問題が発生しています –

答えて

0

私はプロットに手作業によるサイズをプログラムで設定することで、少しでもそれをハックすることができました。プロットのレイアウトパラメータを取得し、手動で高さを変更することができます。私は高さにある種の問題があるようだと思いますか?

XYPlot plot = (XYPlot) findViewById(R.id.plot); 
LayoutParams lp = plot.getLayoutParams(); 
lp.height = 1710; // You can set it to whatever height you require it to be, 1710 is just an example 
plot.setLayoutParams(lp); 
1

ScrollViewの内部で使用するときに、鶏と卵のシナリオを作成し、あなたのプロットの高さ、のためmatch_parentの値を使用しているように、両方のビューが、それはサイズ何それを伝えるために他に依存して見えますなるだろう。

ここで行うべきことは、レイアウトxmlでプロットの高さを明示的に指定することです。これがオプションではない場合は、スクロールビューのXMLに

android:fillViewport="true" 

を追加することもできます。 (通常は動作しますが、さまざまな状況下では逆の報告を聞いています)This blog postは基本的な問題についてもう少し詳しく説明します。

+0

私はすでにandroid:fillViewport = "true"を追加していません(元の投稿に見られるように)。私はプロットの高さをAndroidの画面のサイズに設定しようとしていました。つまり、xmlに明示的に記述することはできませんでした。これはプログラム的に行うことが今のところ最良の選択肢かもしれないかのようです。ありがとう、結構です –

関連する問題