Skip to content

Commit

Permalink
增加AutoLayoutActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
hongyangAndroid committed Nov 20, 2015
1 parent 002b005 commit c514e14
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
public class AutoLinearLayout extends LinearLayout
{

private static final String TAG = "PercentLinearLayout";
private AutoLayoutHelper mPercentLayoutHelper;

public AutoLinearLayout(Context context, AttributeSet attrs)
Expand Down
3 changes: 2 additions & 1 deletion autolayout/src/main/java/zhy/com/autolayout/L.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
*/
public class L
{
public static boolean debug = true;
private static final String TAG = "AUTO_LAYOUT";

public static void e(String msg)
{
if (true)
if (debug)
{
Log.e(TAG, msg);
}
Expand Down
51 changes: 51 additions & 0 deletions sample/src/main/java/com/zhy/sample/AutoLayoutActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.zhy.sample;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.util.AttributeSet;
import android.view.View;

import zhy.com.autolayout.AutoFrameLayout;
import zhy.com.autolayout.AutoLinearLayout;
import zhy.com.autolayout.AutoRelativeLayout;

;

/**
* Created by zhy on 15/11/19.
*/
public class AutoLayoutActivity extends AppCompatActivity
{
private static final String LAYOUT_LINEARLAYOUT = "LinearLayout";
private static final String LAYOUT_FRAMELAYOUT = "FrameLayout";
private static final String LAYOUT_RELATIVELAYOUT = "RelativeLayout";

@Override
public View onCreateView(String name, Context context, AttributeSet attrs)
{
View view = null;
if (name.equals(LAYOUT_FRAMELAYOUT))
{
view = new AutoFrameLayout(context, attrs);
}

if (name.equals(LAYOUT_LINEARLAYOUT))
{
view = new AutoLinearLayout(context, attrs);
}

if (name.equals(LAYOUT_RELATIVELAYOUT))
{
view = new AutoRelativeLayout(context, attrs);
}

if (view != null) return view;


return super.onCreateView(name, context, attrs);
}




}
2 changes: 1 addition & 1 deletion sample/src/main/java/com/zhy/sample/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class MainActivity extends AppCompatActivity
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setContentView(R.layout.activity_main02);
AutoLayout.getInstance().auto(this, true);
}

Expand Down
20 changes: 10 additions & 10 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<zhy.com.autolayout.AutoLinearLayout
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
Expand All @@ -7,7 +7,7 @@
android:orientation="vertical"
tools:context=".MainActivity">

<zhy.com.autolayout.AutoRelativeLayout
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="86px"
android:layout_marginTop="26px"
Expand Down Expand Up @@ -36,10 +36,10 @@
/>


</zhy.com.autolayout.AutoRelativeLayout>
</RelativeLayout>


<zhy.com.autolayout.AutoRelativeLayout
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="108px"
android:layout_marginTop="26px"
Expand All @@ -66,9 +66,9 @@
android:textSize="26px"
/>

</zhy.com.autolayout.AutoRelativeLayout>
</RelativeLayout>

<zhy.com.autolayout.AutoRelativeLayout
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="108px"
android:layout_marginTop="26px"
Expand Down Expand Up @@ -97,9 +97,9 @@
android:textSize="26px"
/>

</zhy.com.autolayout.AutoRelativeLayout>
</RelativeLayout>

<zhy.com.autolayout.AutoRelativeLayout
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="108px"
android:layout_marginTop="26px"
Expand Down Expand Up @@ -128,7 +128,7 @@
android:textSize="26px"
/>

</zhy.com.autolayout.AutoRelativeLayout>
</RelativeLayout>


</zhy.com.autolayout.AutoLinearLayout>
</LinearLayout>
121 changes: 100 additions & 21 deletions sample/src/main/res/layout/activity_main02.xml
Original file line number Diff line number Diff line change
@@ -1,55 +1,134 @@
<zhy.com.autolayout.AutoFrameLayout
<zhy.com.autolayout.AutoLinearLayout
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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#AAcccccc"
android:orientation="vertical"
tools:context=".MainActivity">

<zhy.com.autolayout.AutoLinearLayout
android:orientation="horizontal"
<zhy.com.autolayout.AutoRelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:layout_auto_height="180"
android:layout_height="86px"
android:layout_marginTop="26px"
android:background="#ffffffff"
>

<ImageView
android:id="@+id/id_tv_add"
android:layout_width="34px"
android:layout_height="34px"
android:layout_gravity="center_vertical"
android:layout_marginLeft="276px"
android:layout_marginTop="26px"
android:src="@mipmap/add"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_auto_height="180"
android:background="#44ff0000"
app:layout_auto_width="180"
android:layout_centerVertical="true"
android:layout_marginLeft="26px"
android:layout_toRightOf="@id/id_tv_add"
android:text="新增旅客"
android:textColor="#1fb6c4"
android:textSize="32px"
/>


</zhy.com.autolayout.AutoRelativeLayout>


<zhy.com.autolayout.AutoRelativeLayout
android:layout_width="match_parent"
android:layout_height="108px"
android:layout_marginTop="26px"
android:background="#ffffffff"
>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_auto_height="180"
app:layout_auto_width="180"
android:background="#86fcff"
android:layout_marginLeft="22px"
android:layout_marginTop="16px"
android:text="王大炮 WANG.DAPAO"
android:textColor="#333"
android:textSize="28px"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="16px"
android:layout_marginLeft="22px"
android:text="护照:G50786449"
android:textColor="#999"
android:textSize="26px"
/>

</zhy.com.autolayout.AutoRelativeLayout>

<zhy.com.autolayout.AutoRelativeLayout
android:layout_width="match_parent"
android:layout_height="108px"
android:layout_marginTop="26px"
android:background="#ffffffff"
>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_auto_height="180"
android:background="#ea91ff"
app:layout_auto_width="180"
android:layout_marginLeft="22px"
android:layout_marginTop="16px"
android:text="王大炮 WANG.DAPAO"
android:textColor="#333"
android:textSize="28px"
/>


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_auto_height="180"
android:background="#3989ff"
app:layout_auto_width="180"
android:layout_alignParentBottom="true"
android:layout_marginBottom="16px"
android:layout_marginLeft="22px"
android:text="护照:G50786449"
android:textColor="#999"
android:textSize="26px"
/>

</zhy.com.autolayout.AutoRelativeLayout>

<zhy.com.autolayout.AutoRelativeLayout
android:layout_width="match_parent"
android:layout_height="108px"
android:layout_marginTop="26px"
android:background="#ffffffff"
>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="22px"
android:layout_marginTop="16px"
android:text="王大炮 WANG.DAPAO"
android:textColor="#333"
android:textSize="28px"
/>


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="16px"
android:layout_marginLeft="22px"
android:text="护照:G50786449"
android:textColor="#999"
android:textSize="26px"
/>

</zhy.com.autolayout.AutoLinearLayout>
</zhy.com.autolayout.AutoRelativeLayout>


</zhy.com.autolayout.AutoFrameLayout>
</zhy.com.autolayout.AutoLinearLayout>
29 changes: 0 additions & 29 deletions sample/src/main/res/layout/activity_main03.xml

This file was deleted.

0 comments on commit c514e14

Please sign in to comment.