Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8095497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:09:00+00:00 2026-06-05T21:09:00+00:00

Trying to create a black line in my view to separate text blocks but

  • 0

Trying to create a black line in my view to separate text blocks but its not showing up.
The text shows up as it should but i don’t see the line.

EDIT:
Have tested to add both dynamically as suggested and also to modify my code but still no line? Am i missing something?

Also this is inside a Fragment, class extends Fragment {}

Xml code:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:id="@+id/travelContainer"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >
    </LinearLayout>

</ScrollView>

Java code:

    public class Travel extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

    return inflater.inflate(R.layout.travel_fragment, container, false);
}


@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onViewCreated(view, savedInstanceState);

LinearLayout layout = (LinearLayout)view.findViewById(R.id.travelContainer);

        TextView text = new TextView(getActivity()); 
        int padding = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,4, getActivity().getResources().getDisplayMetrics()); 
        text.setPadding(padding, padding, padding, padding);
        text.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
        text.setTypeface(null, Typeface.BOLD);
        text.setText("TITLE");
        text.setId(123456789);
        layout.addView(text); 

        /* 
    View v = new View(getActivity());
    LinearLayout.LayoutParams viewLp = new LayoutParams(LayoutParams.FILL_PARENT,1);
    viewLp.setMargins(0, 5, 0, 5);
    v.setLayoutParams(viewLp);
    v.setBackgroundColor(0x000);
            */

    View v = getActivity().getLayoutInflater().inflate(R.layout.line, (ViewGroup)getActivity().getCurrentFocus(), false);
    layout.addView(v);


        text = new TextView(getActivity()); 
        padding = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,4, getActivity().getResources().getDisplayMetrics()); 
        text.setPadding(padding, padding, padding, padding);
        text.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10);       
        text.setText("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.");
        layout.addView(text); 
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T21:09:01+00:00Added an answer on June 5, 2026 at 9:09 pm

    Do you need to create the View programatically?

    An easy approach is creating a View with following attributes

    <View
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:background="#000" />
    

    If you create a new XML file called line.xml you can use a LayoutInflater to get the view dynamically:

    View line = MyActivity.this.getLayoutInflater().inflate(R.layout.line, (ViewGroup) getCurrentFocus(), false);
    

    This version will result in a much cleaner code as the system does all the work for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a separator line in my android view. The setup I
I am trying to create textview with text color as black and strikthrough as
I am trying to create a string literal in visual C sharp. i don't
Hey everyone. I am trying to create a black bar, the size of the
Im trying to create a simple callback using blocks. I have a MainViewController which
hi in my app i am trying to make an text view and edit
Im trying to create a horizontal List sing html and css but when is
Im trying to create a moving back ground. My goal is to have a
I am trying to create a function that will block access to some of
So I'm trying to create canvas elements using the information passed back by The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.