textview里面的scrollview(评分片段)

时间:2012-12-11 18:00:34

标签: android

我发现剪切了自己应用的速度:http://www.androidsnippets.com/prompt-engaged-users-to-rate-your-app-in-the-android-market-appirater

个性化这段代码我不能在snipped创建的textview中插入一个scrollview(没有xml但是使用java代码):

    LinearLayout ll = new LinearLayout(mContext);
    ll.setOrientation(LinearLayout.VERTICAL);

    TextView tv = new TextView(mContext);
    tv.setText("If you enjoy using " + APP_TITLE + ", please take a moment to rate it. Thanks for your support!");
    tv.setWidth(240);
    tv.setPadding(4, 0, 4, 10);
    ll.addView(tv);

1 个答案:

答案 0 :(得分:1)

您可以将TextView包装在另一个布局中(就像您一样),然后将所有内容包装在ScrollView中。为此:

ScrollView sc = new ScrollView(mContext);
sc.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
sc.setFillViewport(true);

sc.addView(ll);