开发者

Drawing into scrollView

开发者 https://www.devze.com 2023-04-03 23:50 出处:网络
my problem I know is simple, but for the life of me I cant get an answer... I have a LinearLayout that got a scrollview inside it... in the scroll view (in code) it should call a custom S开发者_Stack

my problem I know is simple, but for the life of me I cant get an answer...

I have a LinearLayout that got a scrollview inside it... in the scroll view (in code) it should call a custom S开发者_StackOverflowcrollView to show on the application... it only shows black, nothing in it... here is my code

first the xml... simple LL with a textview, scrollview and button

<?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>

Now the onCreate of that activity

@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 is the class of the custom scrollView declared like so (it does have onDraw and everything. If I set the contentview to the Draw2d object directly it'll show no problem, but I need it withen a LL)

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

        }  

Please any help is appreciated


Maybe because of you have nothing in the ScrollView? Try putting something in it. Check this link, you see there is another linear layout in the scrollview with "30px" layout height making the scrollview appear. If the layout_height was wrap_content, you would not see the scrollview if there is enough place on the screen for it.

0

精彩评论

暂无评论...
验证码 换一张
取 消