2

对于 kindle fire 中的应用程序,我想让屏幕没有软键。

为此,我将清单更新为

<activity
    android:name=".MainActivity"
    android:label="@string/title_activity_main"
    android:screenOrientation="landscape"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.HOME" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

代码:

@Override
public void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    super.onCreate(savedInstanceState);

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_main); 
    myLayout = (LinearLayout) findViewById(R.id.myLayout);
    myLayout.setBackgroundResource(R.drawable.bgfinal);

    createMainView();
}

@Override
public void onAttachedToWindow()
{
    this.getWindow().setType(WindowManager.LayoutParams.FLAG_FULLSCREEN); 

    super.onAttachedToWindow(); 
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    return false;
}

public void createMainView()
{
    LinearLayout HomePage = new LinearLayout(this);

    HomePage.setOrientation(LinearLayout.VERTICAL);

    HomePage.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    myLayout.addView(HomePage);
    TextView name = new TextView(this); 

    name.setGravity(Gravity.CENTER);
    name.setMinHeight(46);
    HomePage.addView(name);
    LinearLayout HomePageHorLayOut = new LinearLayout(this);
    HomePageHorLayOut.setOrientation(LinearLayout.HORIZONTAL);

    HomePageHorLayOut.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    HomePage.addView(HomePageHorLayOut);

    TextView name1 = new TextView(this);    

    name1.setGravity(Gravity.CENTER);
    name1.setText("     ");
    name1.setWidth(274);
    HomePageHorLayOut.addView(name1);

    final Button PIBtn=new Button(this);
    PIBtn.setBackgroundResource(R.drawable.pilatest);
    PIBtn.setLayoutParams(new LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    HomePageHorLayOut.addView(PIBtn); 
    PIBtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            startActivity(new Intent(android.provider.Settings.ACTION_DATE_SETTINGS));
        }
    });
}

在这种情况下,无论何时启动应用程序,屏幕都没有任何软键,但只要按下按钮,kindle fire 就会将用户带到时间设置框架,即使我们返回应用程序,软键也不会隐藏。

我发现,已经报告了几乎相同的问题,但我已经尝试过这个答案,但结果是一样的。

从设置返回主应用程序时,是否有任何选项可以隐藏软键?

4

0 回答 0