Last active
February 5, 2022 21:28
-
-
Save 2tanayk/4256001df6168740e641da482aed3a3b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:id="@+id/linearLayout" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:gravity="center" | |
android:orientation="vertical" | |
tools:context=".MyActivity"> | |
<include layout="@layout/my_linear_layout" /> | |
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="200dp" | |
android:layout_height="200dp" | |
android:gravity="center"> | |
<TextView | |
android:id="@+id/textView2" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Second Activity" | |
android:textAppearance="@style/TextAppearance.AppCompat.Large" /> | |
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_my); | |
LinearLayout parent = findViewById(R.id.linearLayout); | |
//by doing this we lose all our theme customisation | |
LayoutInflater layoutInflater = LayoutInflater.from(getApplicationContext()); | |
View myLinearLayout = layoutInflater.inflate(R.layout.my_linear_layout, parent, false); | |
parent.addView(myLinearLayout); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment