Vista de lista con vista de desplazamiento horizontal
Estoy tratando de hacer una vista de lista que consiste en una vista de desplazamiento horizontal como cada una de las filas. Quiero que los elementos se alineen verticalmente para que la vista se pueda desplazar si hay más de una cierta cantidad de elementos.
Sin embargo, se ve así.
Estoy inflando el siguiente xml
single_row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:background="#FFFFFF"
android:layout_height="fill_parent">
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.example.jj.library.ChipView
android:layout_weight="1"
android:id="@+id/text_chip_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
Este es mi adaptador para agregar las vistas a la vista
Adapter.java
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import com.example.jj.library.Chip;
import com.example.jj.library.ChipView;
import com.example.jj.library.ChipViewAdapter;
import com.example.jj.library.OnChipClickListener;
import java.util.ArrayList;
import java.util.List;
/**
* Created by jj on 12/21/2015.
*/
public class LiveFeedAdapter extends ArrayAdapter<LiveFeedDataProvider> implements OnChipClickListener {
private static final String TAG = "LIVEFEED ADAPTER";
Context CTX;
private ChipView mTextChipLayout;
public List<LiveFeedDataProvider> liveFeed_list = new ArrayList<LiveFeedDataProvider>();
public LiveFeedAdapter(Context context, int resource) {
super(context, resource);
CTX = context;
}
@Override
public void add(LiveFeedDataProvider object){
liveFeed_list.add(object);
super.add(object);
}
@Override
public int getCount() {
return liveFeed_list.size();
}
@Override
public LiveFeedDataProvider getItem(int position) {
return liveFeed_list.get(position);
}
@Override
public View getView(final int position, View convertView, final ViewGroup parent) {
if(convertView == null){
LayoutInflater inflator = (LayoutInflater) CTX.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflator.inflate(R.layout.single_livefeed_row,parent,false);
}
ChipViewAdapter adapterLayout = new MainChipViewAdapter(getContext());
mTextChipLayout = (ChipView) convertView.findViewById(R.id.text_chip_layout);
mTextChipLayout.setAdapter(adapterLayout);
mTextChipLayout.setChipLayoutRes(R.layout.chip_close);
mTextChipLayout.setChipBackgroundColor(CTX.getResources().getColor(R.color.light_blue));
mTextChipLayout.setChipBackgroundColorSelected(CTX.getResources().getColor(R.color.green));
mTextChipLayout.setOnChipClickListener(this);
LiveFeedDataProvider provider = liveFeed_list.get(position);
Log.d(TAG, "LENGTH = " + provider.interests.length);
for(int i = 0; i < provider.interests.length; i++) {
String interest = provider.interests[i];
mTextChipLayout.add(new Tag(interest));
}
return convertView;
}
@Override
public void onChipClick(Chip chip) {
}
}