New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demonstrate diff when inflating layouts with and without a parent. #9

Open
wants to merge 1 commit into
base: master
from
Jump to file or symbol
Failed to load files and symbols.
+152 −10
Diff settings

Always

Just for now

Demonstrate diff when inflating layouts with and without a parent.

  • Loading branch information...
zmdominguez committed Jun 21, 2017
commit b2d248fc81e56fa9bb81c0f19203698f3b0360ca
@@ -38,28 +38,30 @@
android:name=".PercentLayoutActivity"
android:label="33%!">
</activity>
<activity
android:name=".LinearLayoutActivity"
android:label="LinearLayoutDemo">
</activity>
<activity
android:name=".RecyclerViewViewStubs"
android:label="RecyclerView + ViewStubs">
</activity>
<activity
android:name=".DataBindingSpans"
android:label="DataBinding + Spans">
</activity>
<activity android:name=".ConstraintLayoutDemo"
android:label="Constraint Layout" />
<activity android:name=".ReadableTextActivity"
android:label="Readable Text" />
<activity
android:name=".ConstraintLayoutDemo"
android:label="Constraint Layout"/>
<activity
android:name=".ReadableTextActivity"
android:label="Readable Text"/>
<activity android:name=".bottomsheet.BottomSheetShare"/>
<activity android:name=".bottomsheet.CustomShareActivity"
<activity
android:name=".bottomsheet.CustomShareActivity"
android:label="Choose Me!"/>
<activity android:name=".InflateLayoutParams">
</activity>
</application>
</manifest>
</manifest>
@@ -0,0 +1,34 @@
package com.zdominguez.sdksandbox;
import android.databinding.DataBindingUtil;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.LinearLayout;
import com.zdominguez.sdksandbox.databinding.ActivityInflateLayoutParamsBinding;
import com.zdominguez.sdksandbox.databinding.ItemInflatedLayoutBinding;
public class InflateLayoutParams extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityInflateLayoutParamsBinding binding =
DataBindingUtil.setContentView(this, R.layout.activity_inflate_layout_params);
inflateNoParent(binding.noParentContainer);
inflateWithParent(binding.withParentContainer);
}
private void inflateNoParent(LinearLayout noParentContainer) {
noParentContainer.addView(ItemInflatedLayoutBinding.inflate(getLayoutInflater()).getRoot());
noParentContainer.addView(ItemInflatedLayoutBinding.inflate(getLayoutInflater()).getRoot());
noParentContainer.addView(ItemInflatedLayoutBinding.inflate(getLayoutInflater()).getRoot());
}
private void inflateWithParent(LinearLayout withParentContainer) {
withParentContainer.addView(ItemInflatedLayoutBinding.inflate(getLayoutInflater(), withParentContainer, false).getRoot());
withParentContainer.addView(ItemInflatedLayoutBinding.inflate(getLayoutInflater(), withParentContainer, false).getRoot());
withParentContainer.addView(ItemInflatedLayoutBinding.inflate(getLayoutInflater(), withParentContainer, false).getRoot());
}
}
@@ -211,6 +211,11 @@ public void onDataBindingLambda() {
}
public void onInflateLayoutParams() {
Intent intent = new Intent(this, InflateLayoutParams.class);
startActivity(intent);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.zdominguez.sdksandbox.InflateLayoutParams">
<LinearLayout
android:id="@+id/no_parent_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:background="#54b2de"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/with_parent_container"
app:layout_constraintVertical_chainStyle="spread_inside">
<TextView
android:id="@+id/textView4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="No parent"/>
</LinearLayout>
<LinearLayout
android:id="@+id/with_parent_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#d2d27c"
android:orientation="vertical"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/no_parent_container"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintVertical_chainStyle="spread_inside">
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="With parent"/>
</LinearLayout>
</LinearLayout>
</layout>
@@ -105,10 +105,18 @@
android:layout_height="wrap_content"
android:text="Bottom Sheet Sharing"/>
<Button android:id="@+id/data_binding_click"
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="@{() -> handlers.onInflateLayoutParams()}"
android:text="Inflate layout params"/>
<Button
android:id="@+id/data_binding_click"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="@{() -> handlers.onDataBindingLambda()}"
android:visibility="gone"
android:text="Data Binding Lambdas"/>
<EditText
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
</data>
<LinearLayout
android:orientation="vertical"
android:layout_marginTop="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="Heading"/>
<TextView
android:id="@+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:text="Caption"/>
<TextView
android:id="@+id/textView6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:text="Text"/>
</LinearLayout>
</layout>