Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Saturday, April 30, 2016

Text Not Getting Displayed In Scrollview

Text Not Getting Displayed In Scrollview


I have a scrollview and a text view in it. I want to display the text in the textview scrollable.

XML FILE

                                      

APPLE.java CLASS

package com.example.fruitsinfo;    import android.app.Activity;  import android.os.Bundle;  import android.util.Log;  import android.widget.ImageView;  import android.widget.ScrollView;  import android.widget.TextView;    public class apple  extends Activity{      ImageView apple;      ScrollView sv;      TextView tv;      @Override        protected void onCreate(Bundle savedInstanceState) {          // TODO Auto-generated method stub          super.onCreate(savedInstanceState);          setContentView(R.layout.apple);          apple=(ImageView) findViewById(R.id.imageView1);          Log.d("asfdasf","apple class");          sv=(ScrollView) findViewById(R.id.SonucScrollView);          tv=(TextView) findViewById(R.id.SonucTextView);        }    }  

I have a scrollview and a text view in it. I want to display the text in the textview scrollable.

Answer by GrIsHu for Text Not Getting Displayed In Scrollview


Try to put your TextView inside ScrollView. You have not kept it inside Scrollview it seems in your code.

The Scrollview will always need to have sub child as any Layout. So you have to put some layout as a subchild of ScrollView and in that layout you can keep your TextView.

Try out as below:

                                                                    

Answer by Lokesh for Text Not Getting Displayed In Scrollview


Put your TextView inside ScrollView in XML like:

                                      

Answer by Android for Text Not Getting Displayed In Scrollview


The Scrollview will always need to have sub child as any Layout.thats why you need...

                                                                                                         

Add this 2 line to textview

android:maxLines="10"              android:scrollbars="vertical"  

And into java file

tv_desc = (TextView) findViewById(R.id.YOURTEXTID);      scrollView1.setOnTouchListener(new OnTouchListener() {                  @Override                  public boolean onTouch(View arg0, MotionEvent arg1) {                      // TODO Auto-generated method stub Log.v("PARENT",                      // "PARENT TOUCH");                        findViewById(R.id.tv_desc).getParent()                              .requestDisallowInterceptTouchEvent(false);          return false;                  }              });        tv_desc.setMovementMethod(new ScrollingMovementMethod());             tv_desc.setOnTouchListener(new OnTouchListener() {                    @Override                  public boolean onTouch(View arg0, MotionEvent arg1) {                        arg0.getParent().requestDisallowInterceptTouchEvent(true);                      return false;                  }              });  

Answer by Sethu for Text Not Getting Displayed In Scrollview


    try this one..      In your Layout of XML file try to put scrollview inside of the Textview..          use Linear Layout in this place.                    

Answer by M-sAnNan for Text Not Getting Displayed In Scrollview


just write your

TextView

inside

ScrollView

tag

          


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.