0
我正在使用Android Studio 1.2.2,并且我遇到了无法解决的scrollView问题。 问题是,如果我向scrollview添加一个按钮,那么当我滚动面板时,按钮会留下模糊的痕迹。 (如在旧窗户,当PC冻结,在画面上移动的窗口会导致留下桌面痕迹,如桌面不会被重画)Android Studio ScrollView模糊内容
灰色正方形按钮在底部,你可以看到它下面有更多的按钮,其中实际上没有,它只是没有重绘背景
这个问题发生在通过编辑xml或构建followind时GUI编程式
- 只添加一个或多个按钮直接滚动型
- 添加TableLayout到滚动型,然后加入的TableRow,到我添加按钮
- 添加TableLayout到滚动型,然后加入的TableRow,到我添加帧布局和到该按钮
请,如果你们知道在哪里可能是问题,你能指出我在正确的方向?下面我GameActivity.java
public class GameActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//hide status bar
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
ActionBar actionBar = getActionBar();
actionBar.hide();
setContentView(R.layout.activity_game);
//add components
mImageView = (ImageView) findViewById(R.id.ID_HealthImageView);
mImageView.setImageResource(R.drawable.test);
//init table layout content
createGui_FillTable((TableLayout) findViewById(R.id.ID_table_layout), 6, 3, 210);
}
private void createGui_FillTable(TableLayout tl, int rows, int cols, int size_of_button)
{
if(rows <= 0 || cols <= 0)
return;
for(int z = 0; z < rows; z++) {
TableRow TR = new TableRow(this);
TR.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
for (int i = 0; i < cols; i++)
TR.addView(create_button_forTable(size_of_button));
tl.addView(TR, new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.WRAP_CONTENT));
}
}
private Button create_button_forTable(int size_of_button)
{
//frame layout first
/*FrameLayout FL = new FrameLayout(this);
FL.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));*/
//button
Button B = new Button(this);
B.setText("");
B.setLayoutParams(new TableRow.LayoutParams(size_of_button, size_of_button));
//FL.addView(B);
return B;
}
这里提供的代码
的代码,把重点放在主要方法是下面的调用
createGui_FillTable((TableLayout) findViewById(R.id.ID_table_layout), 6, 3, 210);
现在Activity_game.xml包含此代码(完整的剪切和粘贴)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="janglaser.survival.GameActivity">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/ID_HealthImageView"
android:layout_alignParentBottom="true"
android:layout_marginBottom="48dp" />
<ScrollView
android:layout_width="300dp"
android:layout_height="400dp"
android:id="@+id/scrollView"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_marginTop="50dp"
android:layout_marginLeft="50dp">
<TableLayout
android:id="@+id/ID_table_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignBottom="@+id/ID_HealthImageView"
android:layout_centerHorizontal="true"
android:orientation="horizontal">
</TableLayout>
</ScrollView>
感谢您的任何反馈或建议,如果您在这里发现,也是您的时间。