How to layout @ java
2020-02-01 20:11
537 查看
To layout @ xml is ....., not to discuss any more.
Today, to list how to layout @ java.
1. to define an layout to LinearLayout or TableLayout, and to set its orient.
2. to defines some View and its attribute.
3. to add it into layout.
That's all!
Today, to list how to layout @ java.
1. to define an layout to LinearLayout or TableLayout, and to set its orient.
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
2. to defines some View and its attribute.
TextView tv = new TextView(this);
tv.setText("Hello Android!");
tv.setGravity(1);
LinearLayout.LayoutParams param =
new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
3. to add it into layout.
layout.addView(tv,param);
That's all!
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- Java, ProGuard, and Ant - How to obfuscate Java class files with ProGuard
- How to parse the overloading methods in Java 5.0
- Java - How to write Thread-Safe Code in Java
- how-to: resolve "java.lang.OutOfMemoryError: Java heap space" during using beeline && hiveserver2
- 如何设置Java桌面程序界面外观(How to Set the Look and Feel)
- JAVA: HOW TO AUTO-DETECT A FILE'S ENCODING
- Java - How to create new Entry (key, value)
- How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version 51.0
- How to Write Doc Comments for the Javadoc Tool
- How to install Java 3d robot simulator
- JavaCC How to access non-terminal's TOKEN child
- 如何设置Java桌面程序界面外观(How to Set the Look and Feel) UIManager
- How to Set Classpath for Java on Windows and Linux
- How to solve "\Java\jdk1.7.0_45' was unexpected at this time." while starting jboss-eap-6.2
- How to use use zip/unzip in java?
- How to convert Java object to / from JSON (Gson)
- How to Use Auto Layout in XCode 6 for iOS 7 and 8 Development
- java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.LinearLayout
- How to resolve java.lang.ClassNotFoundException in Java
- how to solve "java.sql.Timestamp does not have a no-arg default constructor" ?