How to show Scrollview images horizontally having 2 columnsReact native listview add item not workinghow to make ScrollView horizontal in react nativeShow splash screen before show main screen in react native without using 3rd party librarySlower performance on iOS release than developmentScrollView HorizontalComponent won't stay wrapped within bounds (React Native)fetch data in react native from mlabNot able to navigate to other page in react nativenavigate from another screen on click navigationDrawerLayout menuundefined-is-not-an-object-evaluating-this-state-datasource.map

Does anyone recognize these rockets, and their location?

Is there a polite way to ask about one's ethnicity?

How to recover a single blank shot from a film camera

how to find which software is doing ssh connection?

Why swap space doesn't get filesystem check at boot time?

In windows systems, is renaming files functionally similar to deleting them?

Is there a risk to write an invitation letter for a stranger to obtain a Czech (Schengen) visa?

Right indicator flash-frequency has increased and rear-right bulb is out

How to sort human readable size

Does cooling a potato change the nature of its carbohydrates?

In a Fish that is not a Fish

What kind of chart is this?

When is the phrase "j'ai bon" used?

Simplify, equivalent for (p ∨ ¬q) ∧ (¬p ∨ ¬q)

How to prevent cables getting intertwined

If the mass of the Earth is decreasing by sending debris in space, does its angular momentum also decrease?

How can caller ID be faked?

Is this broken pipe the reason my freezer is not working? Can it be fixed?

Why can't I craft scaffolding in Minecraft 1.14?

Print the new site header

Time at 1G acceleration to travel 100 000 light years

How much steel armor can you wear and still be able to swim?

What is the precise meaning of "подсел на мак"?

What does this Swiss black on yellow rectangular traffic sign with a symbol looking like a dart mean?



How to show Scrollview images horizontally having 2 columns


React native listview add item not workinghow to make ScrollView horizontal in react nativeShow splash screen before show main screen in react native without using 3rd party librarySlower performance on iOS release than developmentScrollView HorizontalComponent won't stay wrapped within bounds (React Native)fetch data in react native from mlabNot able to navigate to other page in react nativenavigate from another screen on click navigationDrawerLayout menuundefined-is-not-an-object-evaluating-this-state-datasource.map






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















Hii i want to display images horizontally having 2 columns for this i am using scrollview but i dont know how to do that , i am using following code



code to fetch api



 componentDidMount()
return fetch('https://www.json-generator.com/api/json/get/ccLAsEcOSq?indent=1')
.then((response) => response.json())
.then((responseJson) =>
this.setState(
isLoading: false,
dataSource: responseJson.book_array,
, function()
);
)
.catch((error) =>
console.error(error);
);




code for render



render() 
if (this.state.isLoading === true)
return <ActivityIndicator color='red' />;

return (
<View style=styles.container>
<ScrollView horizontal=true>
this.state.dataSource.map(item => this.renderItem(item))
</ScrollView>
</View>
);



}



code for renderItem



renderItem(item) 
return (
<View style= margin: 5 >
<View style=
backgroundColor: 'red',
width: 150,
height: 150,
marginBottom: 1,
>
<Image style= width: 150,height: 150
source=uri: item.image/>
</View>

<View style=
backgroundColor: 'red',
width: 150,
height: 150,
marginBottom: 1,
>
<Image style= width: 150,height: 150
source=uri: item.image/>
</View>

</View>
);









share|improve this question

















  • 1





    Before rendering the view, you need to divide your original array into even and odd array,by adding even/odd check. Then just render those array using Flatlist or using map function or whatever suitable component you want.

    – Poonam
    Mar 25 at 7:32












  • I know but i dont know how to do this..

    – Hector4888
    Mar 25 at 7:34

















0















Hii i want to display images horizontally having 2 columns for this i am using scrollview but i dont know how to do that , i am using following code



code to fetch api



 componentDidMount()
return fetch('https://www.json-generator.com/api/json/get/ccLAsEcOSq?indent=1')
.then((response) => response.json())
.then((responseJson) =>
this.setState(
isLoading: false,
dataSource: responseJson.book_array,
, function()
);
)
.catch((error) =>
console.error(error);
);




code for render



render() 
if (this.state.isLoading === true)
return <ActivityIndicator color='red' />;

return (
<View style=styles.container>
<ScrollView horizontal=true>
this.state.dataSource.map(item => this.renderItem(item))
</ScrollView>
</View>
);



}



code for renderItem



renderItem(item) 
return (
<View style= margin: 5 >
<View style=
backgroundColor: 'red',
width: 150,
height: 150,
marginBottom: 1,
>
<Image style= width: 150,height: 150
source=uri: item.image/>
</View>

<View style=
backgroundColor: 'red',
width: 150,
height: 150,
marginBottom: 1,
>
<Image style= width: 150,height: 150
source=uri: item.image/>
</View>

</View>
);









share|improve this question

















  • 1





    Before rendering the view, you need to divide your original array into even and odd array,by adding even/odd check. Then just render those array using Flatlist or using map function or whatever suitable component you want.

    – Poonam
    Mar 25 at 7:32












  • I know but i dont know how to do this..

    – Hector4888
    Mar 25 at 7:34













0












0








0








Hii i want to display images horizontally having 2 columns for this i am using scrollview but i dont know how to do that , i am using following code



code to fetch api



 componentDidMount()
return fetch('https://www.json-generator.com/api/json/get/ccLAsEcOSq?indent=1')
.then((response) => response.json())
.then((responseJson) =>
this.setState(
isLoading: false,
dataSource: responseJson.book_array,
, function()
);
)
.catch((error) =>
console.error(error);
);




code for render



render() 
if (this.state.isLoading === true)
return <ActivityIndicator color='red' />;

return (
<View style=styles.container>
<ScrollView horizontal=true>
this.state.dataSource.map(item => this.renderItem(item))
</ScrollView>
</View>
);



}



code for renderItem



renderItem(item) 
return (
<View style= margin: 5 >
<View style=
backgroundColor: 'red',
width: 150,
height: 150,
marginBottom: 1,
>
<Image style= width: 150,height: 150
source=uri: item.image/>
</View>

<View style=
backgroundColor: 'red',
width: 150,
height: 150,
marginBottom: 1,
>
<Image style= width: 150,height: 150
source=uri: item.image/>
</View>

</View>
);









share|improve this question














Hii i want to display images horizontally having 2 columns for this i am using scrollview but i dont know how to do that , i am using following code



code to fetch api



 componentDidMount()
return fetch('https://www.json-generator.com/api/json/get/ccLAsEcOSq?indent=1')
.then((response) => response.json())
.then((responseJson) =>
this.setState(
isLoading: false,
dataSource: responseJson.book_array,
, function()
);
)
.catch((error) =>
console.error(error);
);




code for render



render() 
if (this.state.isLoading === true)
return <ActivityIndicator color='red' />;

return (
<View style=styles.container>
<ScrollView horizontal=true>
this.state.dataSource.map(item => this.renderItem(item))
</ScrollView>
</View>
);



}



code for renderItem



renderItem(item) 
return (
<View style= margin: 5 >
<View style=
backgroundColor: 'red',
width: 150,
height: 150,
marginBottom: 1,
>
<Image style= width: 150,height: 150
source=uri: item.image/>
</View>

<View style=
backgroundColor: 'red',
width: 150,
height: 150,
marginBottom: 1,
>
<Image style= width: 150,height: 150
source=uri: item.image/>
</View>

</View>
);






react-native






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 25 at 5:08









Hector4888Hector4888

1291113




1291113







  • 1





    Before rendering the view, you need to divide your original array into even and odd array,by adding even/odd check. Then just render those array using Flatlist or using map function or whatever suitable component you want.

    – Poonam
    Mar 25 at 7:32












  • I know but i dont know how to do this..

    – Hector4888
    Mar 25 at 7:34












  • 1





    Before rendering the view, you need to divide your original array into even and odd array,by adding even/odd check. Then just render those array using Flatlist or using map function or whatever suitable component you want.

    – Poonam
    Mar 25 at 7:32












  • I know but i dont know how to do this..

    – Hector4888
    Mar 25 at 7:34







1




1





Before rendering the view, you need to divide your original array into even and odd array,by adding even/odd check. Then just render those array using Flatlist or using map function or whatever suitable component you want.

– Poonam
Mar 25 at 7:32






Before rendering the view, you need to divide your original array into even and odd array,by adding even/odd check. Then just render those array using Flatlist or using map function or whatever suitable component you want.

– Poonam
Mar 25 at 7:32














I know but i dont know how to do this..

– Hector4888
Mar 25 at 7:34





I know but i dont know how to do this..

– Hector4888
Mar 25 at 7:34












5 Answers
5






active

oldest

votes


















1














Instead of ScrollView try FlatList which provides numColumns props which lets you allow to use columns as per your choice.



Instead of this,



<ScrollView horizontal=true>
this.state.dataSource.map(item => this.renderItem(item))
</ScrollView>


Use this,



<FlatList 
data=this.state.dataSource
numColumns=2
renderItem=this.renderItem
/>


For more details of FlatList see Official Docs Here






share|improve this answer























  • hii i want to scroll images horizontally having two columns upper row contain even images and lower row contain odd images

    – Hector4888
    Mar 25 at 5:29


















1














Try flex-direction property:



renderItem(item) 
return (
<View style= margin: 5, flex: 1, flexDirection: "row", justifyContent: "space-around" >
<View style= backgroundColor: "red", width: 150, height: 150, marginBottom: 1 >
<Image style= width: 150, height: 150 source= uri: item.image />
</View>
<View style= backgroundColor: "red", width: 150, height: 150, marginBottom: 1 >
<Image style= width: 150, height: 150 source= uri: item.image />
</View>
</View>
);





share|improve this answer























  • hii i want to scroll images horizontally having two columns upper row contain even images and lower row contain odd images

    – Hector4888
    Mar 25 at 5:29











  • update your question for that

    – ravi
    Mar 25 at 5:46


















1














modify your ScrollView component Like this:



<ScrollView horizontal=true contentContainerStyle=height:300, flexWrap:'wrap'>
this.state.dataSource.map(item => this.renderItem(item))
</ScrollView>





share|improve this answer






























    1














    Use flat list inside scroll view like this



    <FlatList
    horizontal=true
    data=this.state.dataSource
    renderItem=( item ) => (this.renderItem(item))
    />


    rearrange dataSource like this



    array1 = [obj1,obj2,obj3,obj4,obj5,obj6,obj7,
    array2=[[obj1,obj2],[obj3,obj4],[obj5,obj6],[obj7,obj8]]


    and then render item with 2 rows.



    didn't find any other way






    share|improve this answer

























    • hii i want to scroll images horizontally having two columns upper row contain even images and lower row contain odd images

      – Hector4888
      Mar 25 at 5:28











    • add horizontal=true i have updated my answer

      – Vinil Prabhu
      Mar 25 at 5:30











    • both numColumns=2 , horizontal=true cannot use simultaneously , im getting error

      – Hector4888
      Mar 25 at 5:36











    • sorry didn't find any direct solution, but you can copy your array to a new one with each element having 2 objects , i will update the answer soon

      – Vinil Prabhu
      Mar 25 at 6:47


















    1














    To create view as you required need to implement your custom logic. In render function call a intermediate function to get columns in two row:



    render() {
    if (this.state.isLoading === true)
    return <ActivityIndicator color='red' />;

    return (
    <View style=styles.container>
    <ScrollView horizontal=true>
    this.renderHorizantol(this.state.dataSource)
    </ScrollView>
    </View>
    );


    In renderHorizantol function need to set up logic for even or odd rows, i am implementing this on index of dataSource Array:



    renderHorizantol = (dataSource) =>
    let view = []
    for(let i=0 ; i < data.length ; i = i+2)

    let subView = this.renderItem(dataSource[i],dataSource[i+1])
    view.push(subView)

    return view



    In renderItem function pass two element to draw upper and lower row contents:



    renderItem(item1,item2) 
    let image1 = item1["imageUrl"]
    let image2 = item2 ? item2["imageUrl"] : null
    return (
    <View style= margin: 5 >
    <View style=
    backgroundColor: 'red',
    width: 150,
    height: 150,
    marginBottom: 1,
    >
    <Image style= width: 150,height: 150
    source=uri: image1/>
    </View>

    <View style=
    backgroundColor: 'red',
    width: 150,
    height: 150,
    marginBottom: 1,
    >
    <Image style= width: 150,height: 150
    source=uri: image2/>
    </View>
    </View>
    );





    share|improve this answer























    • Thank you bro you solved my problem..

      – Hector4888
      Mar 25 at 11:14











    • @Hector4888 accept the answer if works for you, it helps others too in choosing correct answer.

      – Rocky
      Mar 25 at 11:33











    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55331543%2fhow-to-show-scrollview-images-horizontally-having-2-columns%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    5 Answers
    5






    active

    oldest

    votes








    5 Answers
    5






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Instead of ScrollView try FlatList which provides numColumns props which lets you allow to use columns as per your choice.



    Instead of this,



    <ScrollView horizontal=true>
    this.state.dataSource.map(item => this.renderItem(item))
    </ScrollView>


    Use this,



    <FlatList 
    data=this.state.dataSource
    numColumns=2
    renderItem=this.renderItem
    />


    For more details of FlatList see Official Docs Here






    share|improve this answer























    • hii i want to scroll images horizontally having two columns upper row contain even images and lower row contain odd images

      – Hector4888
      Mar 25 at 5:29















    1














    Instead of ScrollView try FlatList which provides numColumns props which lets you allow to use columns as per your choice.



    Instead of this,



    <ScrollView horizontal=true>
    this.state.dataSource.map(item => this.renderItem(item))
    </ScrollView>


    Use this,



    <FlatList 
    data=this.state.dataSource
    numColumns=2
    renderItem=this.renderItem
    />


    For more details of FlatList see Official Docs Here






    share|improve this answer























    • hii i want to scroll images horizontally having two columns upper row contain even images and lower row contain odd images

      – Hector4888
      Mar 25 at 5:29













    1












    1








    1







    Instead of ScrollView try FlatList which provides numColumns props which lets you allow to use columns as per your choice.



    Instead of this,



    <ScrollView horizontal=true>
    this.state.dataSource.map(item => this.renderItem(item))
    </ScrollView>


    Use this,



    <FlatList 
    data=this.state.dataSource
    numColumns=2
    renderItem=this.renderItem
    />


    For more details of FlatList see Official Docs Here






    share|improve this answer













    Instead of ScrollView try FlatList which provides numColumns props which lets you allow to use columns as per your choice.



    Instead of this,



    <ScrollView horizontal=true>
    this.state.dataSource.map(item => this.renderItem(item))
    </ScrollView>


    Use this,



    <FlatList 
    data=this.state.dataSource
    numColumns=2
    renderItem=this.renderItem
    />


    For more details of FlatList see Official Docs Here







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 25 at 5:18









    Jaydeep GalaniJaydeep Galani

    2,04111134




    2,04111134












    • hii i want to scroll images horizontally having two columns upper row contain even images and lower row contain odd images

      – Hector4888
      Mar 25 at 5:29

















    • hii i want to scroll images horizontally having two columns upper row contain even images and lower row contain odd images

      – Hector4888
      Mar 25 at 5:29
















    hii i want to scroll images horizontally having two columns upper row contain even images and lower row contain odd images

    – Hector4888
    Mar 25 at 5:29





    hii i want to scroll images horizontally having two columns upper row contain even images and lower row contain odd images

    – Hector4888
    Mar 25 at 5:29













    1














    Try flex-direction property:



    renderItem(item) 
    return (
    <View style= margin: 5, flex: 1, flexDirection: "row", justifyContent: "space-around" >
    <View style= backgroundColor: "red", width: 150, height: 150, marginBottom: 1 >
    <Image style= width: 150, height: 150 source= uri: item.image />
    </View>
    <View style= backgroundColor: "red", width: 150, height: 150, marginBottom: 1 >
    <Image style= width: 150, height: 150 source= uri: item.image />
    </View>
    </View>
    );





    share|improve this answer























    • hii i want to scroll images horizontally having two columns upper row contain even images and lower row contain odd images

      – Hector4888
      Mar 25 at 5:29











    • update your question for that

      – ravi
      Mar 25 at 5:46















    1














    Try flex-direction property:



    renderItem(item) 
    return (
    <View style= margin: 5, flex: 1, flexDirection: "row", justifyContent: "space-around" >
    <View style= backgroundColor: "red", width: 150, height: 150, marginBottom: 1 >
    <Image style= width: 150, height: 150 source= uri: item.image />
    </View>
    <View style= backgroundColor: "red", width: 150, height: 150, marginBottom: 1 >
    <Image style= width: 150, height: 150 source= uri: item.image />
    </View>
    </View>
    );





    share|improve this answer























    • hii i want to scroll images horizontally having two columns upper row contain even images and lower row contain odd images

      – Hector4888
      Mar 25 at 5:29











    • update your question for that

      – ravi
      Mar 25 at 5:46













    1












    1








    1







    Try flex-direction property:



    renderItem(item) 
    return (
    <View style= margin: 5, flex: 1, flexDirection: "row", justifyContent: "space-around" >
    <View style= backgroundColor: "red", width: 150, height: 150, marginBottom: 1 >
    <Image style= width: 150, height: 150 source= uri: item.image />
    </View>
    <View style= backgroundColor: "red", width: 150, height: 150, marginBottom: 1 >
    <Image style= width: 150, height: 150 source= uri: item.image />
    </View>
    </View>
    );





    share|improve this answer













    Try flex-direction property:



    renderItem(item) 
    return (
    <View style= margin: 5, flex: 1, flexDirection: "row", justifyContent: "space-around" >
    <View style= backgroundColor: "red", width: 150, height: 150, marginBottom: 1 >
    <Image style= width: 150, height: 150 source= uri: item.image />
    </View>
    <View style= backgroundColor: "red", width: 150, height: 150, marginBottom: 1 >
    <Image style= width: 150, height: 150 source= uri: item.image />
    </View>
    </View>
    );






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 25 at 5:19









    raviravi

    501620




    501620












    • hii i want to scroll images horizontally having two columns upper row contain even images and lower row contain odd images

      – Hector4888
      Mar 25 at 5:29











    • update your question for that

      – ravi
      Mar 25 at 5:46

















    • hii i want to scroll images horizontally having two columns upper row contain even images and lower row contain odd images

      – Hector4888
      Mar 25 at 5:29











    • update your question for that

      – ravi
      Mar 25 at 5:46
















    hii i want to scroll images horizontally having two columns upper row contain even images and lower row contain odd images

    – Hector4888
    Mar 25 at 5:29





    hii i want to scroll images horizontally having two columns upper row contain even images and lower row contain odd images

    – Hector4888
    Mar 25 at 5:29













    update your question for that

    – ravi
    Mar 25 at 5:46





    update your question for that

    – ravi
    Mar 25 at 5:46











    1














    modify your ScrollView component Like this:



    <ScrollView horizontal=true contentContainerStyle=height:300, flexWrap:'wrap'>
    this.state.dataSource.map(item => this.renderItem(item))
    </ScrollView>





    share|improve this answer



























      1














      modify your ScrollView component Like this:



      <ScrollView horizontal=true contentContainerStyle=height:300, flexWrap:'wrap'>
      this.state.dataSource.map(item => this.renderItem(item))
      </ScrollView>





      share|improve this answer

























        1












        1








        1







        modify your ScrollView component Like this:



        <ScrollView horizontal=true contentContainerStyle=height:300, flexWrap:'wrap'>
        this.state.dataSource.map(item => this.renderItem(item))
        </ScrollView>





        share|improve this answer













        modify your ScrollView component Like this:



        <ScrollView horizontal=true contentContainerStyle=height:300, flexWrap:'wrap'>
        this.state.dataSource.map(item => this.renderItem(item))
        </ScrollView>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 25 at 6:44









        MervzsMervzs

        700115




        700115





















            1














            Use flat list inside scroll view like this



            <FlatList
            horizontal=true
            data=this.state.dataSource
            renderItem=( item ) => (this.renderItem(item))
            />


            rearrange dataSource like this



            array1 = [obj1,obj2,obj3,obj4,obj5,obj6,obj7,
            array2=[[obj1,obj2],[obj3,obj4],[obj5,obj6],[obj7,obj8]]


            and then render item with 2 rows.



            didn't find any other way






            share|improve this answer

























            • hii i want to scroll images horizontally having two columns upper row contain even images and lower row contain odd images

              – Hector4888
              Mar 25 at 5:28











            • add horizontal=true i have updated my answer

              – Vinil Prabhu
              Mar 25 at 5:30











            • both numColumns=2 , horizontal=true cannot use simultaneously , im getting error

              – Hector4888
              Mar 25 at 5:36











            • sorry didn't find any direct solution, but you can copy your array to a new one with each element having 2 objects , i will update the answer soon

              – Vinil Prabhu
              Mar 25 at 6:47















            1














            Use flat list inside scroll view like this



            <FlatList
            horizontal=true
            data=this.state.dataSource
            renderItem=( item ) => (this.renderItem(item))
            />


            rearrange dataSource like this



            array1 = [obj1,obj2,obj3,obj4,obj5,obj6,obj7,
            array2=[[obj1,obj2],[obj3,obj4],[obj5,obj6],[obj7,obj8]]


            and then render item with 2 rows.



            didn't find any other way






            share|improve this answer

























            • hii i want to scroll images horizontally having two columns upper row contain even images and lower row contain odd images

              – Hector4888
              Mar 25 at 5:28











            • add horizontal=true i have updated my answer

              – Vinil Prabhu
              Mar 25 at 5:30











            • both numColumns=2 , horizontal=true cannot use simultaneously , im getting error

              – Hector4888
              Mar 25 at 5:36











            • sorry didn't find any direct solution, but you can copy your array to a new one with each element having 2 objects , i will update the answer soon

              – Vinil Prabhu
              Mar 25 at 6:47













            1












            1








            1







            Use flat list inside scroll view like this



            <FlatList
            horizontal=true
            data=this.state.dataSource
            renderItem=( item ) => (this.renderItem(item))
            />


            rearrange dataSource like this



            array1 = [obj1,obj2,obj3,obj4,obj5,obj6,obj7,
            array2=[[obj1,obj2],[obj3,obj4],[obj5,obj6],[obj7,obj8]]


            and then render item with 2 rows.



            didn't find any other way






            share|improve this answer















            Use flat list inside scroll view like this



            <FlatList
            horizontal=true
            data=this.state.dataSource
            renderItem=( item ) => (this.renderItem(item))
            />


            rearrange dataSource like this



            array1 = [obj1,obj2,obj3,obj4,obj5,obj6,obj7,
            array2=[[obj1,obj2],[obj3,obj4],[obj5,obj6],[obj7,obj8]]


            and then render item with 2 rows.



            didn't find any other way







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 25 at 6:50

























            answered Mar 25 at 5:22









            Vinil PrabhuVinil Prabhu

            557616




            557616












            • hii i want to scroll images horizontally having two columns upper row contain even images and lower row contain odd images

              – Hector4888
              Mar 25 at 5:28











            • add horizontal=true i have updated my answer

              – Vinil Prabhu
              Mar 25 at 5:30











            • both numColumns=2 , horizontal=true cannot use simultaneously , im getting error

              – Hector4888
              Mar 25 at 5:36











            • sorry didn't find any direct solution, but you can copy your array to a new one with each element having 2 objects , i will update the answer soon

              – Vinil Prabhu
              Mar 25 at 6:47

















            • hii i want to scroll images horizontally having two columns upper row contain even images and lower row contain odd images

              – Hector4888
              Mar 25 at 5:28











            • add horizontal=true i have updated my answer

              – Vinil Prabhu
              Mar 25 at 5:30











            • both numColumns=2 , horizontal=true cannot use simultaneously , im getting error

              – Hector4888
              Mar 25 at 5:36











            • sorry didn't find any direct solution, but you can copy your array to a new one with each element having 2 objects , i will update the answer soon

              – Vinil Prabhu
              Mar 25 at 6:47
















            hii i want to scroll images horizontally having two columns upper row contain even images and lower row contain odd images

            – Hector4888
            Mar 25 at 5:28





            hii i want to scroll images horizontally having two columns upper row contain even images and lower row contain odd images

            – Hector4888
            Mar 25 at 5:28













            add horizontal=true i have updated my answer

            – Vinil Prabhu
            Mar 25 at 5:30





            add horizontal=true i have updated my answer

            – Vinil Prabhu
            Mar 25 at 5:30













            both numColumns=2 , horizontal=true cannot use simultaneously , im getting error

            – Hector4888
            Mar 25 at 5:36





            both numColumns=2 , horizontal=true cannot use simultaneously , im getting error

            – Hector4888
            Mar 25 at 5:36













            sorry didn't find any direct solution, but you can copy your array to a new one with each element having 2 objects , i will update the answer soon

            – Vinil Prabhu
            Mar 25 at 6:47





            sorry didn't find any direct solution, but you can copy your array to a new one with each element having 2 objects , i will update the answer soon

            – Vinil Prabhu
            Mar 25 at 6:47











            1














            To create view as you required need to implement your custom logic. In render function call a intermediate function to get columns in two row:



            render() {
            if (this.state.isLoading === true)
            return <ActivityIndicator color='red' />;

            return (
            <View style=styles.container>
            <ScrollView horizontal=true>
            this.renderHorizantol(this.state.dataSource)
            </ScrollView>
            </View>
            );


            In renderHorizantol function need to set up logic for even or odd rows, i am implementing this on index of dataSource Array:



            renderHorizantol = (dataSource) =>
            let view = []
            for(let i=0 ; i < data.length ; i = i+2)

            let subView = this.renderItem(dataSource[i],dataSource[i+1])
            view.push(subView)

            return view



            In renderItem function pass two element to draw upper and lower row contents:



            renderItem(item1,item2) 
            let image1 = item1["imageUrl"]
            let image2 = item2 ? item2["imageUrl"] : null
            return (
            <View style= margin: 5 >
            <View style=
            backgroundColor: 'red',
            width: 150,
            height: 150,
            marginBottom: 1,
            >
            <Image style= width: 150,height: 150
            source=uri: image1/>
            </View>

            <View style=
            backgroundColor: 'red',
            width: 150,
            height: 150,
            marginBottom: 1,
            >
            <Image style= width: 150,height: 150
            source=uri: image2/>
            </View>
            </View>
            );





            share|improve this answer























            • Thank you bro you solved my problem..

              – Hector4888
              Mar 25 at 11:14











            • @Hector4888 accept the answer if works for you, it helps others too in choosing correct answer.

              – Rocky
              Mar 25 at 11:33















            1














            To create view as you required need to implement your custom logic. In render function call a intermediate function to get columns in two row:



            render() {
            if (this.state.isLoading === true)
            return <ActivityIndicator color='red' />;

            return (
            <View style=styles.container>
            <ScrollView horizontal=true>
            this.renderHorizantol(this.state.dataSource)
            </ScrollView>
            </View>
            );


            In renderHorizantol function need to set up logic for even or odd rows, i am implementing this on index of dataSource Array:



            renderHorizantol = (dataSource) =>
            let view = []
            for(let i=0 ; i < data.length ; i = i+2)

            let subView = this.renderItem(dataSource[i],dataSource[i+1])
            view.push(subView)

            return view



            In renderItem function pass two element to draw upper and lower row contents:



            renderItem(item1,item2) 
            let image1 = item1["imageUrl"]
            let image2 = item2 ? item2["imageUrl"] : null
            return (
            <View style= margin: 5 >
            <View style=
            backgroundColor: 'red',
            width: 150,
            height: 150,
            marginBottom: 1,
            >
            <Image style= width: 150,height: 150
            source=uri: image1/>
            </View>

            <View style=
            backgroundColor: 'red',
            width: 150,
            height: 150,
            marginBottom: 1,
            >
            <Image style= width: 150,height: 150
            source=uri: image2/>
            </View>
            </View>
            );





            share|improve this answer























            • Thank you bro you solved my problem..

              – Hector4888
              Mar 25 at 11:14











            • @Hector4888 accept the answer if works for you, it helps others too in choosing correct answer.

              – Rocky
              Mar 25 at 11:33













            1












            1








            1







            To create view as you required need to implement your custom logic. In render function call a intermediate function to get columns in two row:



            render() {
            if (this.state.isLoading === true)
            return <ActivityIndicator color='red' />;

            return (
            <View style=styles.container>
            <ScrollView horizontal=true>
            this.renderHorizantol(this.state.dataSource)
            </ScrollView>
            </View>
            );


            In renderHorizantol function need to set up logic for even or odd rows, i am implementing this on index of dataSource Array:



            renderHorizantol = (dataSource) =>
            let view = []
            for(let i=0 ; i < data.length ; i = i+2)

            let subView = this.renderItem(dataSource[i],dataSource[i+1])
            view.push(subView)

            return view



            In renderItem function pass two element to draw upper and lower row contents:



            renderItem(item1,item2) 
            let image1 = item1["imageUrl"]
            let image2 = item2 ? item2["imageUrl"] : null
            return (
            <View style= margin: 5 >
            <View style=
            backgroundColor: 'red',
            width: 150,
            height: 150,
            marginBottom: 1,
            >
            <Image style= width: 150,height: 150
            source=uri: image1/>
            </View>

            <View style=
            backgroundColor: 'red',
            width: 150,
            height: 150,
            marginBottom: 1,
            >
            <Image style= width: 150,height: 150
            source=uri: image2/>
            </View>
            </View>
            );





            share|improve this answer













            To create view as you required need to implement your custom logic. In render function call a intermediate function to get columns in two row:



            render() {
            if (this.state.isLoading === true)
            return <ActivityIndicator color='red' />;

            return (
            <View style=styles.container>
            <ScrollView horizontal=true>
            this.renderHorizantol(this.state.dataSource)
            </ScrollView>
            </View>
            );


            In renderHorizantol function need to set up logic for even or odd rows, i am implementing this on index of dataSource Array:



            renderHorizantol = (dataSource) =>
            let view = []
            for(let i=0 ; i < data.length ; i = i+2)

            let subView = this.renderItem(dataSource[i],dataSource[i+1])
            view.push(subView)

            return view



            In renderItem function pass two element to draw upper and lower row contents:



            renderItem(item1,item2) 
            let image1 = item1["imageUrl"]
            let image2 = item2 ? item2["imageUrl"] : null
            return (
            <View style= margin: 5 >
            <View style=
            backgroundColor: 'red',
            width: 150,
            height: 150,
            marginBottom: 1,
            >
            <Image style= width: 150,height: 150
            source=uri: image1/>
            </View>

            <View style=
            backgroundColor: 'red',
            width: 150,
            height: 150,
            marginBottom: 1,
            >
            <Image style= width: 150,height: 150
            source=uri: image2/>
            </View>
            </View>
            );






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 25 at 9:48









            RockyRocky

            1,32911018




            1,32911018












            • Thank you bro you solved my problem..

              – Hector4888
              Mar 25 at 11:14











            • @Hector4888 accept the answer if works for you, it helps others too in choosing correct answer.

              – Rocky
              Mar 25 at 11:33

















            • Thank you bro you solved my problem..

              – Hector4888
              Mar 25 at 11:14











            • @Hector4888 accept the answer if works for you, it helps others too in choosing correct answer.

              – Rocky
              Mar 25 at 11:33
















            Thank you bro you solved my problem..

            – Hector4888
            Mar 25 at 11:14





            Thank you bro you solved my problem..

            – Hector4888
            Mar 25 at 11:14













            @Hector4888 accept the answer if works for you, it helps others too in choosing correct answer.

            – Rocky
            Mar 25 at 11:33





            @Hector4888 accept the answer if works for you, it helps others too in choosing correct answer.

            – Rocky
            Mar 25 at 11:33

















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55331543%2fhow-to-show-scrollview-images-horizontally-having-2-columns%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현