Форум для тех, кто программирует под Android
Anonymous
Как получить навигационный планку по умолчанию в этом мире Hello?
Сообщение
Anonymous » 18 фев 2025, 15:52
Код: Выделить всё
package com.example.test;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import android.view.ViewGroup.LayoutParams;
import android.view.Gravity;
import android.widget.LinearLayout;
import android.view.WindowManager;
import android.view.View;
import android.view.Window;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView txt = new TextView(this);
txt.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT
));
txt.setText("Hello, world!");
LinearLayout lay = new LinearLayout(this);
lay.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT
));
lay.addView(txt);
setContentView(lay);
}
}
< /code>
AndroidManifest.xml
< /code>
And I get
Where are the three nagivation buttons ? Why is there a fullscreen icon at bottom right ? Is this navigation bar or something else ? How do I get the app window sandwiched between status bar and navigation bar ?
I tested this on Xiaomi Redmi Note 5 Pro (APILEVEL=28).
Подробнее здесь:
https://stackoverflow.com/questions/794 ... ello-world
1739883150
Anonymous
[code]MainActivity.java[/code] [code]package com.example.test; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import android.view.ViewGroup.LayoutParams; import android.view.Gravity; import android.widget.LinearLayout; import android.view.WindowManager; import android.view.View; import android.view.Window; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView txt = new TextView(this); txt.setLayoutParams(new LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT )); txt.setText("Hello, world!"); LinearLayout lay = new LinearLayout(this); lay.setLayoutParams(new LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT )); lay.addView(txt); setContentView(lay); } } < /code> AndroidManifest.xml[/code] < /code> And I get [img]https://i.sstatic.net/MbfiRIpB.jpg[/img] Where are the three nagivation buttons ? Why is there a fullscreen icon at bottom right ? Is this navigation bar or something else ? How do I get the app window sandwiched between status bar and navigation bar ? I tested this on Xiaomi Redmi Note 5 Pro (APILEVEL=28). Подробнее здесь: [url]https://stackoverflow.com/questions/79448328/how-do-i-get-default-navigation-bar-in-this-hello-world[/url]