相关疑难解决方法(0)

使TextView在Android上可滚动

我在textview中显示文本,看起来太长,无法放入一个屏幕.我需要让我的TextView可滚动.我怎样才能做到这一点?

这是代码:

final TextView tv = new TextView(this);
tv.setBackgroundResource(R.drawable.splash);
tv.setTypeface(face);
tv.setTextSize(18);
tv.setTextColor(R.color.BROWN);
tv.setGravity(Gravity.CENTER_VERTICAL| Gravity.CENTER_HORIZONTAL);
tv.setOnTouchListener(new OnTouchListener() {
    public boolean onTouch(View v, MotionEvent e) {
        Random r = new Random();
        int i = r.nextInt(101);
        if (e.getAction() == e.ACTION_DOWN) {
            tv.setText(tips[i]);
            tv.setBackgroundResource(R.drawable.inner);
        }
        return true;
    }
});
setContentView(tv);
Run Code Online (Sandbox Code Playgroud)

android scroll textview

736
推荐指数
18
解决办法
55万
查看次数

单击RecyclerView列表项

我有RecyclerView一个LinearLayoutManagerAdapter:

@Override public int getItemViewType(int position) {
    return position == 0? R.layout.header : R.layout.item;
}
Run Code Online (Sandbox Code Playgroud)

这是header.xml:

<View xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/header"
      android:layout_width="match_parent"
      android:layout_height="@dimen/header_height"
    />
Run Code Online (Sandbox Code Playgroud)

我想要实现的是在我可以点击的地方找到一个.我尝试了很多组合以下属性无济于事:RecyclerViewRecyclerView

      android:background="@android:color/transparent"
      android:background="@null"
      android:clickable="false"
      android:focusable="false"
      android:focusableInTouchMode="false"
      android:longClickable="false"
Run Code Online (Sandbox Code Playgroud)

如何让列表中的第一个项目透明(允许触摸事件到它后面的任何东西),但让它仍然占据空间?

android android-layout android-listview recycler-adapter android-recyclerview

8
推荐指数
1
解决办法
2213
查看次数