Android SET Visibility GONE但仍然可见

时间:2015-09-07 16:11:50

标签: android visibility space visible

我第一次问这里对不起,如果我违反任何规则

所以我的问题是,我怎样才能使某个布局不占用任何空间(所以我仍然可以点击并触摸它背后的东西),但仍然可见?

我的情况: 我正在开发一个应用程序,您可以在其中创建图像,操作和图像以及在其上面的编辑文本(用于重叠图像组合)。 如果编辑文本没有占用空间,我仍然可以触摸并操纵它下面的图像,但是当我将编辑文本键入一个完整的行时,我无法操纵它背后的图像。我已经在按钮之间切换文本/图像编辑(禁用图像onclick / setfocusable false editext)

任何帮助表示赞赏

修改

public void setTextEdit()
{
    textToolsLayout.setVisibility(View.VISIBLE);
    imageToolsLayout.setVisibility(View.INVISIBLE);

    textSablon.setFocusable(true);
    textSablon.setFocusableInTouchMode(true);
    textSablon.setClickable(true);
    textSablon.requestFocus();
    textSablon.setCursorVisible(true);
    textSablon.setEnabled(true);

    InputMethodManager inputMethodManager=(InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.toggleSoftInputFromWindow(fullSablonLayout.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0);

    imgSablon.setEditable(false);
}

public void setImageEdit()
{
    imageToolsLayout.setVisibility(View.VISIBLE);
    textToolsLayout.setVisibility(View.INVISIBLE);

    textSablon.setFocusable(false);
    textSablon.setFocusableInTouchMode(false);
    textSablon.setClickable(false);
    textSablon.setCursorVisible(false);
    textSablon.setEnabled(false);
    textSablon.setOnTouchListener(null);
    imgSablon.setEditable(true);
}

这些是关于点击功能的按钮,imgSablon是编辑文本下的imageview,以及imageview的ONTOP中的textSablon。

再次,我希望edittext仍然可见,但不占用空间,所以我仍然可以触摸它下面的imageview。

有可能吗?

另一种类比: 说有一个按钮,在另一个按钮上面。 单击可见按钮时,请单击顶部按钮。 我希望顶部仍然可见,但它忽略了输入,所以当我尝试点击时,点击BOTTOM BUTTON

我希望这有帮助

1 个答案:

答案 0 :(得分:0)

创建自定义EditText并覆盖onTouchEvent。您可以通过切换一些布尔值touch来控制是否可以触摸视图。

RelativeLayout parent = (RelativeLayout) findViewById(R.id.parent);
parent.addView(new EditText(this){
    @Override
    public boolean onTouchEvent(MotionEvent event) {
        return touch;
    }
});
相关问题