Skip to content

Commit c0227fa

Browse files
committed
initial commit
0 parents  commit c0227fa

24 files changed

+923
-0
lines changed

.gitignore

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# built application files
2+
*.apk
3+
*.ap_
4+
*.jar
5+
6+
# lint folder
7+
lint
8+
9+
# files for the dex VM
10+
*.dex
11+
12+
# Java class files
13+
*.class
14+
15+
# generated files
16+
bin/
17+
gen/
18+
classes/
19+
gen-external-apklibs/
20+
21+
# maven output folder
22+
target
23+
24+
# Local configuration file (sdk path, etc)
25+
local.properties
26+
27+
# Eclipse project files
28+
.classpath
29+
.project
30+
.metadata
31+
.settings
32+
33+
# IntelliJ files
34+
.idea
35+
*.iml
36+
37+
# OSX files
38+
.DS_Store
39+
40+
# Windows files
41+
Thumbs.db
42+
43+
# vi swap files
44+
*.swp
45+
46+
# backup files
47+
*.bak
48+
49+
# gradle directory
50+
.gradle
51+
gradlew
52+
gradlew.bat
53+
build/
54+
autolinearlayout/build
55+
app/build

README.md

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
AutoLinearLayout
2+
===============
3+
4+
Custom layout that arranges views in rows and columns automatically.
5+
Takes care about padding, margins, gravity and layout child gravities.
6+
7+
8+
![Demo Screenshot 1][1]
9+
![Demo Screenshot 2][2]
10+
11+
12+
Usage
13+
-----
14+
15+
To use AutoLinearLayout, add the module into your project and start to build xml or java.
16+
17+
###XML
18+
```xml
19+
<net.grobas.widget.AutoLinearLayout
20+
android:layout_width="match_parent"
21+
android:layout_height="match_parent"
22+
app:gravity="center"
23+
app:orientation="vertical">
24+
<!-- other views -->
25+
</net.grobas.widget.AutoLinearLayout>
26+
```
27+
28+
#####Properties:
29+
30+
* `app:orientation` (int) -> default horizontal
31+
* `app:gravity` (flag) -> default top | left
32+
33+
34+
###JAVA
35+
36+
```java
37+
AutoLinearLayout l2 = new AutoLinearLayout(this);
38+
l2.setOrientation(AutoLinearLayout.VERTICAL);
39+
l2.setGravity(Gravity.CENTER);
40+
//add other views
41+
parent.addView(l2);
42+
```
43+
44+
License
45+
-------
46+
47+
Copyright 2014 Albert Grobas
48+
49+
Licensed under the Apache License, Version 2.0 (the "License");
50+
you may not use this file except in compliance with the License.
51+
You may obtain a copy of the License at
52+
53+
http://www.apache.org/licenses/LICENSE-2.0
54+
55+
Unless required by applicable law or agreed to in writing, software
56+
distributed under the License is distributed on an "AS IS" BASIS,
57+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
58+
See the License for the specific language governing permissions and
59+
limitations under the License.
60+
61+
62+
63+
[1]: ./art/screen01.png
64+
[2]: ./art/screen02.png

app/build.gradle

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 19
5+
buildToolsVersion '20.0.0'
6+
7+
defaultConfig {
8+
applicationId "net.grobas.autolinearlayout.sample"
9+
minSdkVersion 8
10+
targetSdkVersion 19
11+
versionCode 1
12+
versionName "0.1"
13+
}
14+
buildTypes {
15+
release {
16+
runProguard false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
compile 'com.android.support:appcompat-v7:19.+'
24+
compile project(':autolinearlayout')
25+
}

app/proguard-rules.pro

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in F:\Projects\android-sdk\sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}

app/src/main/AndroidManifest.xml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="net.grobas.autolinearlayout.sample" >
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@drawable/ic_launcher"
8+
android:label="@string/app_name"
9+
android:theme="@style/AppTheme" >
10+
<activity
11+
android:name=".SampleActivity"
12+
android:label="@string/app_name" >
13+
<intent-filter>
14+
<action android:name="android.intent.action.MAIN" />
15+
16+
<category android:name="android.intent.category.LAUNCHER" />
17+
</intent-filter>
18+
</activity>
19+
</application>
20+
21+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package net.grobas.autolinearlayout.sample;
2+
3+
import android.os.Bundle;
4+
import android.support.v7.app.ActionBarActivity;
5+
import android.view.Gravity;
6+
import android.view.ViewGroup;
7+
import android.widget.Button;
8+
import android.widget.FrameLayout;
9+
10+
import net.grobas.widget.AutoLinearLayout;
11+
12+
13+
public class SampleActivity extends ActionBarActivity {
14+
15+
@Override
16+
protected void onCreate(Bundle savedInstanceState) {
17+
super.onCreate(savedInstanceState);
18+
setContentView(R.layout.activity_sample);
19+
20+
AutoLinearLayout l = (AutoLinearLayout) findViewById(R.id.layout);
21+
AutoLinearLayout l2 = new AutoLinearLayout(this);
22+
l2.setOrientation(AutoLinearLayout.VERTICAL);
23+
l2.setGravity(Gravity.CENTER);
24+
25+
for(int i = 0; i < 24; i++) {
26+
Button b = new Button(this);
27+
b.setText("child"+i);
28+
l2.addView(b, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
29+
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) b.getLayoutParams();
30+
lp.gravity = Gravity.CENTER;
31+
}
32+
l.addView(l2);
33+
}
34+
}
9.18 KB
Loading
5.11 KB
Loading
Loading
18.9 KB
Loading
+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
<net.grobas.widget.AutoLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:app="http://schemas.android.com/apk/res-auto"
3+
android:id="@+id/layout"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:padding="10dp"
7+
app:orientation="vertical">
8+
<!--
9+
<Button
10+
android:layout_width="wrap_content"
11+
android:layout_height="wrap_content"
12+
android:text="child1" />
13+
14+
<Button
15+
android:layout_width="wrap_content"
16+
android:layout_height="wrap_content"
17+
android:text="child2" />
18+
19+
<Button
20+
android:layout_width="150dp"
21+
android:layout_height="100dp"
22+
android:text="child3" />
23+
24+
<Button
25+
android:layout_width="wrap_content"
26+
android:layout_height="wrap_content"
27+
android:text="child4" />
28+
29+
<Button
30+
android:layout_width="wrap_content"
31+
android:layout_height="wrap_content"
32+
android:layout_marginBottom="2dp"
33+
android:layout_gravity="center"
34+
android:layout_marginLeft="10dp"
35+
android:layout_marginRight="15dp"
36+
android:layout_marginTop="10dp"
37+
android:text="child5" />
38+
39+
<Button
40+
android:layout_width="wrap_content"
41+
android:layout_height="wrap_content"
42+
android:text="child6" />
43+
44+
<Button
45+
android:layout_width="wrap_content"
46+
android:layout_height="wrap_content"
47+
android:text="child7" />
48+
49+
<Button
50+
android:layout_width="100dp"
51+
android:layout_height="70dp"
52+
android:text="child8" />
53+
54+
<Button
55+
android:layout_width="wrap_content"
56+
android:layout_height="wrap_content"
57+
android:text="child9" />
58+
59+
<Button
60+
android:layout_width="wrap_content"
61+
android:layout_height="wrap_content"
62+
android:text="child11" />
63+
64+
<Button
65+
android:layout_width="wrap_content"
66+
android:layout_height="wrap_content"
67+
android:text="child12" />
68+
69+
<Button
70+
android:layout_width="wrap_content"
71+
android:layout_height="wrap_content"
72+
android:text="child13" />
73+
74+
<Button
75+
android:layout_width="wrap_content"
76+
android:layout_height="wrap_content"
77+
android:text="child14" />
78+
79+
<Button
80+
android:layout_width="wrap_content"
81+
android:layout_height="wrap_content"
82+
android:text="child15" />
83+
84+
<Button
85+
android:layout_width="wrap_content"
86+
android:layout_height="wrap_content"
87+
android:text="child16" />
88+
89+
<Button
90+
android:layout_width="wrap_content"
91+
android:layout_height="wrap_content"
92+
android:text="child17" />
93+
94+
<Button
95+
android:layout_width="wrap_content"
96+
android:layout_height="wrap_content"
97+
android:text="child18" />
98+
99+
<Button
100+
android:layout_width="wrap_content"
101+
android:layout_height="wrap_content"
102+
android:text="child19" />
103+
104+
<Button
105+
android:layout_width="wrap_content"
106+
android:layout_height="wrap_content"
107+
android:text="child20" />
108+
109+
<Button
110+
android:layout_width="wrap_content"
111+
android:layout_height="wrap_content"
112+
android:text="child21" />
113+
114+
<Button
115+
android:layout_width="wrap_content"
116+
android:layout_height="wrap_content"
117+
android:text="child22" />
118+
119+
<Button
120+
android:layout_width="wrap_content"
121+
android:layout_height="wrap_content"
122+
android:text="child23" />
123+
124+
<Button
125+
android:layout_width="wrap_content"
126+
android:layout_height="wrap_content"
127+
android:text="child24" />
128+
129+
<Button
130+
android:layout_width="wrap_content"
131+
android:layout_height="wrap_content"
132+
android:text="child25" />
133+
-->
134+
135+
</net.grobas.widget.AutoLinearLayout>
136+

app/src/main/res/values/strings.xml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
4+
<string name="app_name">AutoLinearLayout Sample</string>
5+
6+
7+
</resources>

app/src/main/res/values/styles.xml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<resources>
2+
3+
<!-- Base application theme. -->
4+
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
5+
<!-- Customize your theme here. -->
6+
</style>
7+
8+
</resources>

art/screen01.png

41.9 KB
Loading

art/screen02.png

39.4 KB
Loading

0 commit comments

Comments
 (0)