{"id":1814,"date":"2010-04-19T18:14:59","date_gmt":"2010-04-19T22:14:59","guid":{"rendered":"http:\/\/www.gubatron.com\/blog\/?p=1814"},"modified":"2010-04-19T18:14:59","modified_gmt":"2010-04-19T22:14:59","slug":"android-making-a-textview-scrollable","status":"publish","type":"post","link":"https:\/\/www.gubatron.com\/blog\/android-making-a-textview-scrollable\/","title":{"rendered":"Android: Making a TextView Scrollable"},"content":{"rendered":"<p>I needed a TextView to take the rest of the screen realstate. This TextView would behave as a logging component.<br \/>\nI tried using android:singleLine=&#8221;false&#8221; but that didn&#8217;t cut it.<\/p>\n<p>What I did:<br \/>\nAdd a ScrollView (with android:fillViewport=&#8221;true&#8221; and android:layout_weight=&#8221;1&#8243;), then add a LinearLayout (yup&#8230;), and then add the TextView to fill all of that up (android:layout_weight=&#8221;1&#8243; too)<\/p>\n<p>Here&#8217;s the only thing that worked for me:<br \/>\n[code lang=&#8221;xml&#8221;]<br \/>\n\t&lt;ScrollView android:layout_width=&quot;fill_parent&quot;<br \/>\n                              android:layout_height=&quot;wrap_content&quot;<br \/>\n                              android:layout_weight=&quot;1&quot; android:fillViewport=&quot;true&quot;&gt;<br \/>\n\t\t&lt;LinearLayout android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;fill_parent&quot;&gt;<br \/>\n\t\t&lt;TextView android:text=&quot;@+id\/TextView01&quot;<br \/>\n\t\t\tandroid:id=&quot;@+id\/logTextView&quot;<br \/>\n\t\t\tandroid:layout_width=&quot;fill_parent&quot;<br \/>\n\t\t\tandroid:layout_height=&quot;fill_parent&quot;<br \/>\n\t\t\tandroid:textColor=&quot;#000&quot;<br \/>\n\t\t\tandroid:background=&quot;#fff&quot;<br \/>\n\t\t\tandroid:layout_weight=&quot;1&quot;&gt;&lt;\/TextView&gt;<br \/>\n\t\t&lt;\/LinearLayout&gt;<br \/>\n\t&lt;\/ScrollView&gt;<br \/>\n[\/code]<\/p>\n<p>Then on your Activity, do this:<br \/>\n[java]<br \/>\n_logTextView = (TextView) findViewById(R.id.logTextView);<br \/>\n_logTextView.setText(&quot;&quot;);<\/p>\n<p>\/\/and here comes the magic<br \/>\n_logTextView.setMovementMethod(ScrollingMovementMethod.getInstance());<br \/>\n[\/java] <\/p>\n","protected":false},"excerpt":{"rendered":"<p>I needed a TextView to take the rest of the screen realstate. This TextView would behave as a logging component. I tried using android:singleLine=&#8221;false&#8221; but that didn&#8217;t cut it. What I did: Add a ScrollView (with android:fillViewport=&#8221;true&#8221; and android:layout_weight=&#8221;1&#8243;), then add a LinearLayout (yup&#8230;), and then add the TextView to fill all of that up [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[5,30],"tags":[],"class_list":["post-1814","post","type-post","status-publish","format-standard","hentry","category-android","category-geeklife"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Unzf-tg","jetpack-related-posts":[{"id":2887,"url":"https:\/\/www.gubatron.com\/blog\/android-changing-textview-alpha-transparency-across-different-target-sdks\/","url_meta":{"origin":1814,"position":0},"title":"Android: Changing TextView alpha transparency across different target SDKs","author":"gubatron","date":"November 30, 2012","format":false,"excerpt":"Sometimes you may need to make a TextView (label) look a little transparent to make emphasis on other parts of your UI. The .setAlpha() function on TextView is not supported after later in the SDK. Here's a static workaround you can place on some sort of UIUtils class you may\u2026","rel":"","context":"In \"Android\"","block_context":{"text":"Android","link":"https:\/\/www.gubatron.com\/blog\/tag\/android\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1913,"url":"https:\/\/www.gubatron.com\/blog\/how-to-do-unit-testing-on-android-with-eclipse\/","url_meta":{"origin":1814,"position":1},"title":"[SCREENCAST] How to do Unit Testing on Android with Eclipse","author":"gubatron","date":"May 2, 2010","format":false,"excerpt":"I was going to make a tutorial, but then I figured that making a video would be a much better way to show this. As for the code that you could grab from a tutorial, there's a link at the end of the post with all the code shown in\u2026","rel":"","context":"In &quot;Android&quot;","block_context":{"text":"Android","link":"https:\/\/www.gubatron.com\/blog\/category\/android\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/androinica.com\/wp-content\/uploads\/2008\/10\/android_logo.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2170,"url":"https:\/\/www.gubatron.com\/blog\/geek-t-shirt-collection-27-android-t-shirt\/","url_meta":{"origin":1814,"position":2},"title":"Geek T-Shirt Collection #27 &#8211; Android T-Shirt","author":"gubatron","date":"February 14, 2011","format":false,"excerpt":"I'm an Android, all the way. Self-made Android T-Shirt, I tend to use this one when I know there's a hard android hacking day ahead of me. It's an awesome tshirt to wear at Apple related events. See the Previous T-Shirt See the Next T-Shirt","rel":"","context":"In &quot;GeekShirts&quot;","block_context":{"text":"GeekShirts","link":"https:\/\/www.gubatron.com\/blog\/category\/geekshirts\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2783,"url":"https:\/\/www.gubatron.com\/blog\/quick-peek-at-frostwire-for-android-1-0\/","url_meta":{"origin":1814,"position":3},"title":"Quick Peek at the next generation of FrostWire for Android (1.0.x)","author":"gubatron","date":"September 27, 2012","format":false,"excerpt":"Try the Android 1.0.0 beta installer Here's a sneak peak of the next generation flagship file sharing client for the mobile world. This next generation will include a brand new user interface with a more streamlined experience, you'll be able to search, access and consume your files better than ever\u2026","rel":"","context":"In &quot;Android&quot;","block_context":{"text":"Android","link":"https:\/\/www.gubatron.com\/blog\/category\/android\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2117,"url":"https:\/\/www.gubatron.com\/blog\/frostwire-for-android-desktop-integration-demo\/","url_meta":{"origin":1814,"position":4},"title":"FrostWire for Android Desktop Integration Demo","author":"gubatron","date":"December 18, 2010","format":false,"excerpt":"Very convenient way to send files back and forth to your Android Phone or Tablet. Absolutely free at frostwire.com All source code available on bitbucket.org","rel":"","context":"In &quot;Android&quot;","block_context":{"text":"Android","link":"https:\/\/www.gubatron.com\/blog\/category\/android\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3020,"url":"https:\/\/www.gubatron.com\/blog\/how-to-avoid-android-compilationbuilding-issues-setting-up-the-eclipse-buildpath-correctly\/","url_meta":{"origin":1814,"position":5},"title":"How to avoid Android compilation\/building issues &#8211; Setting up the Eclipse Buildpath correctly","author":"gubatron","date":"May 21, 2013","format":false,"excerpt":"This post is the product of about 48 hours of not being able to work on what I was supposed to be working because I had to deal with build issues in Eclipse. Hopefully If you follow these steps you will be able to solve some of the issues you\u2026","rel":"","context":"In &quot;Android&quot;","block_context":{"text":"Android","link":"https:\/\/www.gubatron.com\/blog\/category\/android\/"},"img":{"alt_text":"Screen Shot 2013-05-21 at 12.13.46 PM","src":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2013\/05\/Screen-Shot-2013-05-21-at-12.13.46-PM.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2013\/05\/Screen-Shot-2013-05-21-at-12.13.46-PM.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2013\/05\/Screen-Shot-2013-05-21-at-12.13.46-PM.png?resize=525%2C300 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/1814","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/comments?post=1814"}],"version-history":[{"count":0,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/1814\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/media?parent=1814"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/categories?post=1814"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/tags?post=1814"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}