Skip to content

Commit 508253e

Browse files
committed
fix awesometextview not respecting android:gravity if present
1 parent ea1a1f1 commit 508253e

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/AwesomeTextView.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,13 @@ private void initialise(AttributeSet attrs) {
113113
markdownText = a.getString(R.styleable.AwesomeTextView_bootstrapText);
114114

115115
setClickable(clickable); // allows view to reach android:state_pressed
116+
117+
int gravity = a.getInt(R.styleable.AwesomeTextView_android_gravity, Gravity.CENTER);
118+
setGravity(gravity);
116119
}
117120
finally {
118121
a.recycle();
119122
}
120-
setGravity(Gravity.CENTER);
121123

122124
if (markdownText != null) {
123125
setMarkdownText(markdownText);

AndroidBootstrap/src/main/res/values/attrs.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
<attr name="typicon"/>
6464
<attr name="materialIcon" />
6565
<attr name="android:clickable" />
66+
<attr name="android:gravity" />
6667
</declare-styleable>
6768

6869
<declare-styleable name="BootstrapLabel">

sample/src/main/res/layout/example_awesome_text_view.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@
140140
style="@style/wrapping_fa_text"
141141
android:textSize="30dp"
142142
app:bootstrapBrand="primary"
143-
app:bootstrapText="Escaped \{fa_facebook\} icon"
143+
app:bootstrapText="Escaped \{fa_facebook\} icon (gravity=start)"
144+
android:gravity="start"
144145
tools:ignore="SpUsage"
145146
/>
146147

sample/src/main/res/layout/example_bootstrap_button.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,8 @@
466466
android:layout_width="match_parent"
467467
android:layout_height="wrap_content"
468468
android:layout_marginTop="@dimen/micro_padding"
469-
android:gravity="center"
470-
android:text="Matching"
469+
android:gravity="right"
470+
android:text="Matching (gravity right)"
471471
app:bootstrapBrand="info"
472472
/>
473473

sample/src/main/res/layout/example_bootstrap_label.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@
244244
android:layout_width="match_parent"
245245
android:layout_height="wrap_content"
246246
android:layout_marginTop="@dimen/micro_padding"
247-
android:gravity="center"
248-
android:text="Match Parent"
247+
android:gravity="end"
248+
android:text="Match Parent (gravity end)"
249249
app:bootstrapBrand="primary"
250250
/>
251251

0 commit comments

Comments
 (0)