2012-01-05 25 views
6

複雑なエフェクトを含むポップアップメニューを実装したいのですが、その1つはスクロールをサポートすることです。 PopupMenuとAlertDialogは私の必要条件を満たせません。そこで私はScrollViewでPopupWindowを試しました。 )(二次PopupWindowのScrollViewでのスクロール効果がありません

ScrollView 
    LinearLayout with Vertical attribute 
     TextView 
     TextView 
     TextView 
     ... 

、私は、どこかshowAtLocationでそれを示して、このレイアウトでPopupWindowを新たにし、200width/300height:

まず、私はちょうどApiDemoを示して何のようなシンプルなstrctureを持っていレイアウトを準備しました。

スクロールバーを表示させることができますが、スクロール効果はありますが、LinearLayoutのTextViewはスクロールしません(固定位置にあります)!

何かが間違っていますが、私はそれに意味がありません。 (android3.0)

私にいくつかのヒントを与えることができる暖かい心の男のためにありがとう。

-_- !!

答えて

0

私はあなたの要件は、私は私も同様の問題に直面した

protected void showInputDialog() { 
     final Dialog splRerDialog = new Dialog(getContext()); 
     splRerDialog.setTitle("Special request."); 

     ScrollView scroll = new ScrollView(getContext()); 

     LinearLayout lin = new LinearLayout(getContext()); 
     lin.setLayoutParams(new LayoutParams(350,200)); 
     lin.setGravity(Gravity.CENTER); 
     lin.setOrientation(LinearLayout.VERTICAL); 

     final EditText req = new EditText(getContext()); 
     req.setLayoutParams(new LayoutParams(300,300)); 
     lin.addView(req); 

     Button btn = new Button(getContext()); 
     btn.setText("Ok"); 
     btn.setLayoutParams(new LayoutParams(200,LayoutParams.WRAP_CONTENT)); 
     btn.setGravity(Gravity.CENTER); 

     btn.setOnClickListener(new View.OnClickListener() { 

      public void onClick(View arg0) { 
       splRerDialog.dismiss(); 
      } 
     }); 
     lin.addView(btn); 

     scroll.addView(lin); 

     splRerDialog.addContentView(scroll, new LayoutParams(LayoutParams.WRAP_CONTENT,200)); 

     splRerDialog.show(); 
    } 
2

を与えているコードを試してみてくださいダイアログでfullfilledすることができると思います。 scrollupの相対レイアウトをwrappingする方法がpopupwindowでうまくいかないことがあります。

私はスクロールビューの下で個々のビューをラップしようとしました。 PLeaseは下を見ます。これが役に立てば幸いです

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/container" 
android:layout_width="fill_parent" 
android:layout_height="match_parent" 
android:background="#eebd9c" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
> 
    <ScrollView 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_centerHorizontal="true" 
    android:layout_below="@+id/textView2" > 

    <TextView 
     android:id="@+id/textView9" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:ellipsize="marquee" 
     android:ems="15" 
     android:gravity="fill_horizontal" 
     android:minLines="6" 
     android:scrollbars="vertical" 
     android:singleLine="false" 
     android:text="Multiline text" 
     android:textAppearance="?android:attr/textAppearanceSmall" /> 
    </ScrollView></RelativeLayout> 
関連する問題