Android Button mit Pfeil nach rechts

LucasZL

Mitglied
Ich versuche einen Button zu erstellen der Text zeigt und rechts am Rand einen Pfeil nach rechts ungefähr so wie im Anhang. Den Button habe ich, nur zur anschauung, folgendermaßen gemacht:
[XML]<Button
android:id="@+id/btnLogin"
android:layout_width="fill_parent"
android:layout_height="30sp"
android:layout_marginTop="20dp"
android:text="Hier steht ein Ort >"
android:background="@drawable/buttonlayoutselector"
android:textColor="@android:color/black"/>[/XML]

[XML]<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@drawable/layoutbuttonclicked" android:state_pressed="true"/>
<item android:drawable="@drawable/layoutbutton"/>

</selector>[/XML]

[XML]<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<gradient android:startColor="#fff"
android:endColor="#fff"
android:angle="270" />
<corners android:radius="5dp" />
<stroke android:width="1px" android:color="#0021a6" />
</shape>

[/XML]

Gibt es eine Möglichkeit den Pfeil unabhängig vom Text einzufügen? Denn der Text ist später dynamisch dann passt das mit den Leerzeichen nicht. Habe auch schon android:drawableRight="@drawable/pfeil" ausprobiert, das überdeckt aber immer einen Teil des Buttonrandes.
 

Anhänge

  • Bildschirmfoto 2013-12-23 um 16.09.20.png
    Bildschirmfoto 2013-12-23 um 16.09.20.png
    3 KB · Aufrufe: 35

dzim

Top Contributor
Ich hätte jetzt vielleicht noch einen Text View mit drawableRight versucht. Auch wenn es kein button ist, kannst du ja deinen selector übergeben, dann sieht er trotzdem so aus. Und die Listener sind die selben.

Alternativ verwende ein linearLayout und richte alles so aus, wie du es brauchst und Lehre deinen selector und deinen listener auf das layout.

Vielleicht bringt das ja was...
 
Zuletzt bearbeitet:
Ähnliche Java Themen
  Titel Forum Antworten Datum
T Android Studio: Einen Button in einer For Schleife verwenden Android & Cross-Platform Mobile Apps 2
W App deinstallieren per Button & Andere App Öffnen per Button Android & Cross-Platform Mobile Apps 24
W Apk automatisch installieren per Button Android & Cross-Platform Mobile Apps 55
W aus Fragmente in andere Klasse wechseln mit Button Android & Cross-Platform Mobile Apps 3
T App updaten via Button Android & Cross-Platform Mobile Apps 10
AGW Android Teilen Button ändern Android & Cross-Platform Mobile Apps 14
A Button in SurfaceView integrieren Android & Cross-Platform Mobile Apps 10
J Android App - Browser öffnen und Text eingeben/Button click auslösen Android & Cross-Platform Mobile Apps 10
L Button zum Quadrad zwingen Android & Cross-Platform Mobile Apps 2
S Android Absoluter Neuling: EditText zur Laufzeit verändern bzw. über Button Android & Cross-Platform Mobile Apps 2
L Dialog anzeigen wenn auf Button gedrückt wird. Android & Cross-Platform Mobile Apps 4
S Android ListFragment & ArrayAdapter - Button-Werte werden vergessen Android & Cross-Platform Mobile Apps 0
B Android Abfragen wie lang ein Button gedrückt wurde Android & Cross-Platform Mobile Apps 2
J Android button mithilfe einer Methode automatisch erstellen Android & Cross-Platform Mobile Apps 6
A AlertDialog Enable Button Android & Cross-Platform Mobile Apps 1
J Button array ID Problem Android & Cross-Platform Mobile Apps 2
D Android Activity wechseln per Button Android & Cross-Platform Mobile Apps 3
B Android ringProgressDialog nach Erfolg Button einfärben Android & Cross-Platform Mobile Apps 2
A Android Menü Button oben links Android & Cross-Platform Mobile Apps 1
B Mit Button GeräteEinstellung des Handys öffnen Android & Cross-Platform Mobile Apps 3
M Android Android "Up-Button" extra definieren? Android & Cross-Platform Mobile Apps 1
K Problem mit arraylist und button Android & Cross-Platform Mobile Apps 16
T Button aktivieren per Qullcode... Android & Cross-Platform Mobile Apps 3
T Button geht net... Android & Cross-Platform Mobile Apps 2
D Man sieht nicht ob Button gedrückt wurde! Android & Cross-Platform Mobile Apps 10
K Grafik Tablerow, Button erstreckt sich in der gesamten Breite trotz Beschrenkung durch (max)width Android & Cross-Platform Mobile Apps 2
G Button ein Wert zuweisen Android & Cross-Platform Mobile Apps 5
M 20 Image Button für jede Auflösung positionieren Android & Cross-Platform Mobile Apps 3
B Android Button erstellen nach Vorlage Android & Cross-Platform Mobile Apps 4
M Einzel Verarbeitung welcher Button angeklickt wurde? Android & Cross-Platform Mobile Apps 6
G Back-Button Methode überschreiben Android & Cross-Platform Mobile Apps 2
P Android Option Button Android & Cross-Platform Mobile Apps 4
G Check Button ist unchecked trotz setChecked(true) Android & Cross-Platform Mobile Apps 6
G Android Button mit Bild Android & Cross-Platform Mobile Apps 4
W Android App Programmierung - Button ganz transparent machen Android & Cross-Platform Mobile Apps 3
L Custom Dialog Button event Android & Cross-Platform Mobile Apps 2
J Button rechtsbündig Android & Cross-Platform Mobile Apps 5
A Android Button Array? Android & Cross-Platform Mobile Apps 6
P Android Button mit bild versehen Android & Cross-Platform Mobile Apps 4
J "Button" auf List erstellen Android & Cross-Platform Mobile Apps 4
U Fire button und Command.BACK, 1 kommen sich in die quere Android & Cross-Platform Mobile Apps 2
AllBlack Auf der Suche nach einem App-Entwickler Android & Cross-Platform Mobile Apps 1
J Android zugrif auf Thread nach Handy drehen. Android & Cross-Platform Mobile Apps 10
AGW App schließt nach 2 Sekunden Android & Cross-Platform Mobile Apps 2
ruutaiokwu Android Daten von "Activity A" nach "Activity B" umleiten? Android & Cross-Platform Mobile Apps 13
A Android-Studio: 2. Layout nach kurzer Zeit aufzeigen Android & Cross-Platform Mobile Apps 2
B Profilpic wird nach anmeldung nicht angezeigt. Android & Cross-Platform Mobile Apps 2
J BLOB nach dem Download unbrauchbar Android & Cross-Platform Mobile Apps 0
B App schließt nach Start. Android & Cross-Platform Mobile Apps 12
J Android Nach Appsprachenänderung die Systemsprache ermitteln Android & Cross-Platform Mobile Apps 2
G App wird nach Installation auf Smartphone beendet Android & Cross-Platform Mobile Apps 1
B Android wie kann ich in einer xml nach bestimme item suchen (DOM) Android & Cross-Platform Mobile Apps 7
Fischkralle Android Nach Textdateien in Ordner suchen Android & Cross-Platform Mobile Apps 5
V Android Fehlermeldung beim Öffnen von Eclipse nach Installation der Android Erweiterung Android & Cross-Platform Mobile Apps 4
T Android Nach Buttonclick neu laden Android & Cross-Platform Mobile Apps 3
B Android Activity nach gedrückte Returntaste weiterlaufen lassen Android & Cross-Platform Mobile Apps 2
N PriceScannerApp: warum wird nach dem Scannen Display gleich schwarz? Android & Cross-Platform Mobile Apps 4
L Android Bildschirm bleibt dunkel nach neustarten der App nach betätigen des Home-Buttons Android & Cross-Platform Mobile Apps 3
N Android EditText.setError() funktioniert nicht nach Rotation Android & Cross-Platform Mobile Apps 1
M Android App startet nach Tastensperre neu Android & Cross-Platform Mobile Apps 3
P Android Nach Animation Layout auf alten Platz Android & Cross-Platform Mobile Apps 3
G Werteübergabe nach unbestimmter Zeit Android & Cross-Platform Mobile Apps 28
A Fehlermeldung nach Neuinstallation von Eclipse/bestehenden Projekten... Android & Cross-Platform Mobile Apps 2
E Android App stürzt nach Modifizierung ab Android & Cross-Platform Mobile Apps 2
N Textview macht immer nach einem Beistrich einen Abstand Android & Cross-Platform Mobile Apps 6
K Apps durchsuchen nach verwendeter Methode Android & Cross-Platform Mobile Apps 4
M Android MediaRecorder - Crash nach 2. Start Android & Cross-Platform Mobile Apps 2
S rms recordstore bleibt nach schießen der anwengung nicht erhalten Android & Cross-Platform Mobile Apps 4
M Text in txt-Datei schreiben und nach ABC sortieren? Android & Cross-Platform Mobile Apps 2
H FileConnection: Frage nach Dateisystem-Zugriff unterdrücken Android & Cross-Platform Mobile Apps 5
K suche nach der richtigen dokumentationh Android & Cross-Platform Mobile Apps 2
S ein String nach vorgegebenen Zeichen teilen Android & Cross-Platform Mobile Apps 3
L Ungültiges Java-Archiv (jar) nach Programmentwicklung Android & Cross-Platform Mobile Apps 4

Ähnliche Java Themen

Neue Themen


Oben