Drawing a line dynamically in code

by Kevin Courtney » Wed, 22 Sep 2010 20:54:26 GMT


Sponsored Links
 Hello,



This seems like a basic question but Ie been struggling with it and need
another set of eyes to set me straight.



I trying to draw a line using code in a RelativeLayout and it not
showing up.  I have this XML file:



<?xml version=*"1.0"* encoding=*"utf-8"*?>

<shape xmlns:android=*" http://schemas.android.com/apk/res/android" ;*

android:shape=*"line"*>

    <stroke android:width=*"1dp"* android:colora=*"#0000FF"*/>

    <size android:height=*"15dp"* />

</shape>



I use this file when drawing a line from straight XML and it works fine.


But now I trying to use it to draw a line dynamically, in this code


ScrollView sv = *new* ScrollView(*this*);

      RelativeLayout relativeLayout = *new* RelativeLayout(*this*);

             relativeLayout.setBackgroundResource(R.drawable.*gradient_box*
);



      sv.addView(relativeLayout);



      ImageView imageLineView2 = *new* ImageView(*this*);;

      imageLineView2.setBackgroundResource(R.drawable.*dividing_line_1*);

      RelativeLayout.LayoutParams lpEndOfInfoLineId2 =

       *new* RelativeLayout.LayoutParams(

*           *RelativeLayout.LayoutParams.*WRAP_CONTENT*,

     RelativeLayout.LayoutParams.*FILL_PARENT*);

      relativeLayout.addView(imageLineView2,lpEndOfInfoLineId2);



      // have buttons, text, and images here that show up fine.



      *this*.setContentView(sv);



It uses the same background as my successful use from the XML file so I
don think it blending into the background.



Do any of you have any suggestions on what I missing?



Thanks in advance,



Kevin

--



Drawing a line dynamically in code

by Kumar Bibek » Wed, 22 Sep 2010 23:44:18 GMT


 No you can't. What you are doing is right. If I understand correctly,
you want to use the draw method to draw a line, am I correct?

-Kumar Bibek
 http://techdroid.kbeanie.com 




--


Sponsored Links


Drawing a line dynamically in code

by Kevin Courtney » Thu, 23 Sep 2010 00:35:59 GMT


 I'm not entirely sure if it's the draw method that I should be
using..at this point I'm looking for any suggestions...

...I need to draw a line on the on this view using code.

The rest of the story is that this code is inside a loop that is
reading records and putting their info on the view.  In between each
record I want to draw a simple line.

Thanks,

Kevin





--



Drawing a line dynamically in code

by Kumar Bibek » Thu, 23 Sep 2010 02:02:28 GMT


 If you are using a ListView, that is fairly simple.

Else,
You have two options...
1. Use Imageview as you are doing, if you dont want a Custom View
class.
2. Use a custom view class that draws everything, which is more
difficult.

-Kumar Bibek
 http://techdroid.kbeanie.com 






--



Other Threads

1. The status of Donut and HTC hero

Hi,

Any one knows the status of Donut. There is already leaked HTC Hero
phone. I wonder which version that Hero phone will be based.

Regards,
Johnny Xia.
--~--~---------~--~----~------------~-------~--~----~

2. java.net.HttpURLConnection throws "Received authentication challenge is null"

I am using HttpURLConnection to send a GET request to a server. Upon
reading the response code, the Android implementation of
HttpURLConnection.doRequestInternal() throws an exception:

"java.io.IOException: Received authentication challenge is null"

I don't even get what the error is trying to tell me. I write an OAuth
param string to the Authorization header, but this works fine on other
occasions. There is nothing peculiar about my request apart from that.

Any idea what this means, what is causing this and how to get around
it? This works fine with Sun's Java implementation, so I guess it's a
problem with Apache Harmony?

Thanks!
Matthias
--~--~---------~--~----~------------~-------~--~----~

3. Why the buffer is 0 when I play the "rtsp" movie from the internet?

4. chrome os can execute apk?

5. Getting Contents of LinearLayout Flashing When Pressed

6. Use classes defined inside other applications

7. What is DISABLE_DEXPREOPT ?