Skip to content
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

issue 121 align to bottom #191

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ android {
versionName "0.19"
//resConfigs "en", "de"
buildConfigField "boolean", "enableColorSniffer", "false"
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
buildTypes {
debug {
Expand Down Expand Up @@ -68,6 +69,10 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':flowlayout:layouts')
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2', {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestImplementation 'com.android.support.test:rules:1.0.2'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.2'
}

Expand Down
10 changes: 7 additions & 3 deletions app/src/main/res/layout/activity_launcher.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical">
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true">

<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
android:layout_weight="1"
>

<org.apmem.tools.layouts.FlowLayout
android:id="@+id/home_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|center_horizontal|center_vertical"
android:orientation="horizontal" />
android:orientation="horizontal"
/>

</ScrollView>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/menu/menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
<item
android:id="@+id/menu_rename"
android:title="@string/rename" />

<item
android:id="@+id/menu_freeze_size"
android:title="@string/freeze_size" />
Expand All @@ -51,4 +50,5 @@
android:title="@string/uninstall" />



</menu>
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
public class FlowLayout extends ViewGroup {

private final ConfigDefinition config;
List<LineDefinition> lines = new ArrayList<>();
List<LineDefinition> lines = new ArrayList<>(); //NOPMD - suppressed CommentDefaultAccessModifier - TODO explain reason for suppression
List<ViewDefinition> views = new ArrayList<>();

public FlowLayout(Context context) {
Expand All @@ -45,7 +45,7 @@ public FlowLayout(Context context, AttributeSet attributeSet, int defStyle) {
}

private void readStyleParameters(Context context, AttributeSet attributeSet) {
TypedArray a = context.obtainStyledAttributes(attributeSet, R.styleable.FlowLayout);
TypedArray a = context.obtainStyledAttributes(attributeSet, R.styleable.FlowLayout); //NOPMD - suppressed ShortVariable - TODO explain reason for suppression
try {
this.config.setOrientation(a.getInteger(R.styleable.FlowLayout_android_orientation, CommonLogic.HORIZONTAL));
this.config.setMaxLines(a.getInteger(R.styleable.FlowLayout_maxLines, 0));
Expand Down Expand Up @@ -91,6 +91,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
view.setNewLine(lp.isNewLine());
view.setGravity(lp.getGravity());
view.setWeight(lp.getWeight());

view.setMargins(lp.leftMargin, lp.topMargin, lp.rightMargin, lp.bottomMargin);
views.add(view);
}
Expand Down Expand Up @@ -124,16 +125,18 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
}

/* need to take padding into account */

int totalControlWidth = this.getPaddingLeft() + this.getPaddingRight();
int totalControlHeight = this.getPaddingBottom() + this.getPaddingTop();
if (this.config.getOrientation() == CommonLogic.HORIZONTAL) {
totalControlWidth += contentLength;
totalControlHeight += contentThickness;
totalControlHeight += contentThickness; //NOPMD - suppressed UnusedAssignment - TODO explain reason for suppression
} else {
totalControlWidth += contentThickness;
totalControlHeight += contentLength;
}
this.setMeasuredDimension(resolveSize(totalControlWidth, widthMeasureSpec), resolveSize(totalControlHeight, heightMeasureSpec));
this.setMeasuredDimension(resolveSize(totalControlWidth, widthMeasureSpec), heightMeasureSpec);

}

private void applyPositionsToViews(LineDefinition line) {
Expand Down Expand Up @@ -161,11 +164,17 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
View view = child.getView();
LayoutParams lp = (LayoutParams) view.getLayoutParams();
view.layout(
this.getPaddingLeft() + line.getX() + child.getInlineX() + lp.leftMargin,
this.getPaddingTop() + line.getY() + child.getInlineY() + lp.topMargin,
this.getPaddingLeft() + line.getX() + child.getInlineX() + lp.leftMargin + child.getWidth(),
this.getPaddingTop() + line.getY() + child.getInlineY() + lp.topMargin + child.getHeight()

//this.getPaddingLeft() + line.getX() + child.getInlineX() - lp.leftMargin ,
//this.getPaddingTop() + line.getY() + child.getInlineY() - lp.topMargin+150,
//this.getPaddingLeft() + line.getX() + child.getInlineX() + lp.leftMargin + child.getWidth(),
//this.getPaddingTop() + line.getY() + child.getInlineY() + lp.topMargin+ child.getHeight()+150
this.config.getMaxLength()-this.getPaddingLeft() - line.getX() - child.getInlineX() - lp.leftMargin- child.getWidth(),
this.config.getMaxThickness()+this.getPaddingTop() - line.getY() - child.getInlineY() - lp.topMargin- child.getHeight(),
this.config.getMaxLength()+this.getPaddingLeft() - line.getX() - child.getInlineX() - lp.leftMargin ,
this.config.getMaxThickness()+this.getPaddingTop() - line.getY() - child.getInlineY() - lp.topMargin
);

}
}
}
Expand Down