Displaying XML code of Android Layout removes '' tag to &lt

  • Unknown's avatar

    I want to display XML contents in my blog but I’m facing this issue like whenever I use space or XML code it automatically converts to alternative contents. I’m using wordpress.com.

    The blog I need help with is: (visible only to logged in users)

  • Unknown's avatar

    Hello iamkevinchris,

    Try using the instructions found on this page: https://en.support.wordpress.com/code/posting-source-code/.

    Specifically, try wrapping the XML in:

    [code language="xml"]
    your code here
    [/code]

    If this doesn’t work or wasn’t what you were looking for let me know.

  • Unknown's avatar
    iamkevinchris · Member ·

    No I already tried this it’s not working. < is replaced by &lt.

  • Unknown's avatar

    Hmm, can you perhaps post the code you are attempting to display? And just to make sure I understand you’re trying to include this XML in a post correct?

  • Unknown's avatar
    iamkevinchris · Member ·

    <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android”
    xmlns:tools=”http://schemas.android.com/tools”
    android:layout_width=”match_parent”
    android:layout_height=”match_parent”
    android:paddingBottom=”@dimen/activity_vertical_margin”
    android:paddingLeft=”@dimen/activity_horizontal_margin”
    android:paddingRight=”@dimen/activity_horizontal_margin”
    android:paddingTop=”@dimen/activity_vertical_margin”
    tools:context=”idoandroid.contentprovidersample.Main2Activity”>

    <TextView
    android:layout_width=”wrap_content”
    android:layout_height=”wrap_content”
    android:text=”@string/hello_world” />

    </RelativeLayout>

    This is what I’m trying to post. Its an activity layout xml file.

  • Unknown's avatar
    iamkevinchris · Member ·

    It is displaying properly in the blog. but later if i try to add any space or aligning them cause these problem same thing happens for java code also. I try to align the code by giving spaces but later the java code block spaces were turned into &nsbp; I this is the case how can I align the code?

  • Unknown's avatar

    Just to make sure, you’re putting this in the visual editor correct:

    [code language="xml"]
    
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="idoandroid.contentprovidersample.Main2Activity">
    
    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world" />
    
    </RelativeLayout>
    
    [/code]

    Specifically, have you defined the code language as “xml”? The only way I’m able to replicate this is if the code language is defined as “html.” If it’s defined correctly I can add all the spaces I want and everything displays fine. There’s something in your post that is being interpreted as encoded HTML, hence the entities.

    If it all double checks as I displayed there, can you provide a link to the post in question? On your blog I’m only seeing the home page.

  • The topic ‘Displaying XML code of Android Layout removes '' tag to &lt’ is closed to new replies.