0

私はこの問題を抱えています:

私はHorizo​​ntalScrollVewに3つのWebViewを追加します。

XML

<?xml version="1.0" encoding="utf-8"?> 
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/Scroll"
  android:fillViewport="true"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent">
  <LinearLayout android:id="@+id/container"
      android:orientation="vertical" android:layout_width="fill_parent"
      android:layout_height="fill_parent"></LinearLayout>

</HorizontalScrollView>

コード

protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        SetContentView(Resource.Layout.Main);

        LinearLayout container = FindViewById<LinearLayout>(Resource.Id.container);
        ScrollView  scrollView = FindViewById<HorizontalScrollView>(Resource.Id.Scroll);
      scrollView.HorizontalScrollBarEnabled = true;
        scrollView.VerticalScrollBarEnabled = false;
        int top = 0;
        int left = 0;


        WebView WebView1 = new WebView(this);
        WebView1.LoadUrl("http://...");
        WebView1.HorizontalScrollBarEnabled = false;
        WebView1.VerticalScrollBarEnabled = false;                    
        this._layoutParams = null;
        this._layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent);
        _layoutParams.SetMargins(left, top, 0, 0);          
        container.AddView(WebView1, _layoutParams);            

        WebView WebView2 = new WebView(this);
        WebView2.LoadUrl("http://...");
        WebView2.HorizontalScrollBarEnabled = false;
        WebView2.VerticalScrollBarEnabled = false;
        WebView2.SetMinimumWidth(600);
        WebView2.SetMinimumHeight(500);              
        this._layoutParams = null;
        this._layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FillParent,LinearLayout.LayoutParams.WrapContent);
        left += 300;
        _layoutParams.SetMargins(left, top, 0, 0);         
        container.AddView(WebView2, this._layoutParams);

        WebView WebView3 = new WebView(this);
        WebView3.LoadUrl("http://...");
        WebView3.HorizontalScrollBarEnabled = false;
        WebView3.VerticalScrollBarEnabled = false;
        WebView3.SetMinimumWidth(600);
        WebView3.SetMinimumHeight(500);
        this._layoutParams = null;
        this._layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FillParent,LinearLayout.LayoutParams.WrapContent);
        left += 600;
        _layoutParams.SetMargins(left, top, 0, 0);         
        container.AddView(WebView3, this._layoutParams);   
    } 

ただし、表示されないWebViewがあります。いくつかのWebViewをHorizo​​ntalScrollViewに正しく追加し、それらをfisicalDisplayに表示する方法を教えてください。

ありがとう!

4

1 に答える 1

1

Webビューを線形レイアウトに配置してみることができます。ただし、Webビューはスクロール可能であるため、実際にScrollViewをスクロールすることはできないと思います。プログラムでスクロールする必要があります。または、ViewFlipperを使用することもできます。これにより、カスタムアニメーションを使用することもできます。

于 2011-12-28T14:14:01.713 に答える