I am developing an Android app that has a button which spawns a browser. To make this…
- User
I am developing an Android app that has a button which spawns a browser. To make this clear to the user, I want to add an 'external link' icon after the button text. Which
android:drawableresource should I use? - Assistant
You should use the drawable resource called
ic_exit_to_app. This icon is commonly used to indicate an external link or a link that will take the user away from the current app. - User
Unfortunately I get
Cannot resolve symbol '@android:drawable/ic_exit_to_app'. Is there an alternative? - Assistant
Yes, if you are not able to access
ic_exit_to_app, you can use theic_shareicon which looks similar and can also be used to indicate an external link.Here is how you can use it:
- Copy the
ic_shareicon from the Android Studio Vector Asset Studio:- Right-click on the res folder in your project structure
- Select New > Vector Asset
- Choose "Material Icons" from the drop-down menu for the "Icon Type"
- Select "ic_share" and click "Next"
- Adjust the size and color if needed and click "Finish"
- In your layout.xml file, add the
ImageViewelement after theButtonelement and set itssrcattribute to theic_sharedrawable resource:<Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Open Browser" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_share" /> - Adjust the layout attributes and positioning of the
ImageViewelement to fit your design.
- Copy the
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.