2011-09-12 42 views
0

我的问题,我知道很简单,但对我的生活,我不能得到答案......绘制成滚动视图

我有一个LinearLayout中,进行了滚动型里面......在滚动视图(代码),应该调用自定义滚动型显示应用......它只能显示黑,什么也没有......这里是我的代码

第一的XML ...简单的LL同一个TextView,滚动视图和按钮

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
> 

<TextView android:layout_height="wrap_content" 
android:id="@+id/textView1" 
android:layout_width="wrap_content" 
android:text="test field" android:layout_alignParentTop="true"/>   

<ScrollView android:layout_width="600dp" 
android:layout_height="300dp" 
android:id="@+id/v1" 
android:fillViewport="true"/> 

<Button android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:id="@+id/gfx" 
android:text="Gfx" 
></Button> 

</LinearLayout> 

现在,活动的onCreate

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    requestWindowFeature(Window.FEATURE_NO_TITLE); 

    cw = getWindowManager().getDefaultDisplay().getWidth(); 
    ch = getWindowManager().getDefaultDisplay().getHeight(); 

    v = Draw2d findViewById(R.id.v1); 

    context = this; 
    setContentView(R.layout.gfx); 

    mDbHelper = new DbAdapter(this); 
    mDbHelper.open(); 

} 

Draw2d是自定义scrollView的类声明像这样(它确实有onDraw和一切。如果我设置了内容查看到Draw2D的对象直接,它会显示没有问题,但我需要它withen一个LL)

public static class Draw2d extends ScrollView{ 
     public Draw2d(Context context) { 
      super(context); 

     } 

请任何帮助表示赞赏

回答

0

的也许是因为你没有什么在滚动型?试着把东西放进去。检查this链接,您会看到scrollview中有另一个线性布局,“30px”布局高度使滚动视图出现。如果layout_height是wrap_content,那么如果屏幕上有足够的位置,就不会看到滚动视图。

+0

我有,自定义scrollView中有一个onDraw函数,我没有粘贴在这里。但它确实显示,如果我直接做SetContentView作为类Draw2d ...但我不想这样做,我想设置XML布局 – Hok