开发者

how to merge an image button into an imageview in an android app

i am working on an app for both ios and android. In a particular activity i am showing an imageview full of text. In that i am highlighting particular text with yellow color. When the user clicks over them it takes him to a webpage.

The particular text is been at the middle and at the end of the image. For this in my ios app i got the image with a blank space in between and in those blank spaces i have added an image button, so that when the user clicks it opens the web page. In ios the resolution of the app is to be a fixed one.

i have one more problem here. If the user changes his language to be german or korean currently i am changing the images with the corresponding text in my ios app, but here i have to create text in those language. I felt it to be very hard, tats why i am trying to use image itself....

But how can i do this in my android app. Can anyone help m开发者_如何学Ce in this.


If you do not need to show an image in the ImageView, I suggest to use a TextView instead. You can put all your text in the TextView, and with the android:autoLink="all" attribute, all links to webpages, phonenumbers, maps and email will be highlighted! Also, you can set a background image or background gradient

Here's an example for your main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" 
    android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView 
        android:id="@+id/textView1"
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:background="@drawable/gradient" 
        android:autoLink="all"
        android:text="Email: public@nytimes.com \n
            Phone: 212-556-7652 \n
            Address: 620 Eighth avenue New York, NY 10018 \n 
            Website: http://www.nytimes.com " >
    </TextView>
</LinearLayout>

Here's the code for the background gradient (which you should put in the drawables folder):

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
        <gradient
        android:startColor="#ff305385"
        android:endColor="#ff3A6195"
        android:angle="90" />
</shape>


I am not sure I understand your question completely, but it sounds like you can do it using SpannableString built of text-image-text and set to a TextView

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜