Reputation: 444
I have a FrameLayout which contains an EditText and a Button.
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp">
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/edittext_hint"
android:inputType="textPassword"
android:maxLength="25" />
<Button
android:id="@+id/forgottenPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:background="@null"
android:fontFamily="@font/sf_pro_display_lightitalic"
android:padding="16dp"
android:marginRight="16dp" // still, it gets cropped
android:text="@string/password_button"
android:textSize="18sp" />
</FrameLayout>
I gave padding=16dp
to the Button but somehow the question mark is partially visible. If I make the phrase short like "Forgot it?" then the '?' mark fully visible. I didn't understand. I gave it even marginRight=16dp
, still...
But when I don't set fontFamily
attribute, again it is fully visible.
The confusion I have is that how come the last character gets cropped even though it has padding
and marginRight
. I even tried adding space after the question mark but nothing changed. Am I missing something?
Edit: I am actually using strings.xml
for the button's text. When I add space
after the '?' in the strings.xml
it doesn't effect the text in the button, however, when text is hard coded and added space
after the '?', question mark is fully visible again. But as it is said over and over Hardcoded string is bad.
I can't make my phrase short like "Forgot it?", because the app is in Turkish and the original phrase is relatively long. And also I have to use that font.
Upvotes: 0
Views: 241
Reputation: 1017
That is because your font is italic. If you want to insert a space character in XML file use  
after ?
like this : ? 
.
Upvotes: 3
Reputation: 17854
If all you want is some clickable text, there's no need for a Button:
<TextView
android:id="@+id/forgottenPassword"
android:clickable="true"
android:focusable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:fontFamily="@font/sf_pro_display_lightitalic"
android:padding="16dp"
android:marginRight="16dp"
android:text="@string/password_button"
android:textSize="18sp" />
Notice that I added clickable
and focusable
.
Upvotes: 0
Reputation: 420
That's because of the padding on your button. Remove the padding and try it out.
Upvotes: 0