İf height match_parent override other views
I WANT TO GET LİKE THİS EXPAND AND CLOSE
I WANT TO GET LİKE THİS EXPAND AND CLOSE OTHER EXPANDABLE LİST VİEWS
这是我的xml文件,用于显示可扩展列表等。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ImageView
android:layout_width="55dp"
android:layout_height="55dp"
android:layout_marginBottom="50dp"
android:layout_marginLeft="180dp"
android:background="@drawable/sizeozel_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="150dp"
android:text="SİZE ÖZEL"
android:textSize="24sp"
android:layout_marginTop="55dp"
/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@drawable/size_ozel_divider"
android:layout_marginTop="95dp"
/>
<ExpandableListView
android:id="@+id/exp_referans_linkim"
android:layout_width="match_parent"
android:layout_height="49dp"
android:layout_marginTop="105dp"
android:layout_weight="1"
></ExpandableListView>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@drawable/size_ozel_divider"
android:layout_marginTop="165dp"
/>
<ExpandableListView
android:id="@+id/exp_satislarim"
android:layout_width="match_parent"
android:layout_height="49dp"
android:layout_marginTop="175dp"
android:layout_weight="1"
></ExpandableListView>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@drawable/size_ozel_divider"
android:layout_marginTop="235dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:layout_marginTop="245dp"
android:text="İş Ortaklarım"
/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@drawable/size_ozel_divider"
android:layout_marginTop="270dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:layout_marginTop="280dp"
android:text="Sepetim"
/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@drawable/size_ozel_divider"
android:layout_marginTop="305dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:layout_marginTop="315dp"
android:text="Alınan Ürünler"
/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@drawable/size_ozel_divider"
android:layout_marginTop="340dp"
/>
<ExpandableListView
android:id="@+id/exp_bilgilerim"
android:layout_width="match_parent"
android:layout_height="49dp"
android:layout_marginTop="355dp"
android:layout_weight="1"
></ExpandableListView>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@drawable/size_ozel_divider"
android:layout_marginTop="420dp"
/>
</RelativeLayout>
我的可扩展列表视图的适配器java文件
package arabulkazan.albatros.com.arabulkazan.Adapters;
import android.content.Context;
import android.database.DataSetObserver;
import android.support.constraint.ConstraintLayout;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.List;
import arabulkazan.albatros.com.arabulkazan.MainActivity;
import arabulkazan.albatros.com.arabulkazan.R;
import static arabulkazan.albatros.com.arabulkazan.Fragments.SizeOzel.ref_childListMap;
import static arabulkazan.albatros.com.arabulkazan.Fragments.SizeOzel.ref_groupList;
public class Exp_Ref_List_Adapter implements ExpandableListAdapter {
Context context;
public Exp_Ref_List_Adapter(Context context) {
this.context = context;
}
@Override
public void registerDataSetObserver(DataSetObserver dataSetObserver) {
}
@Override
public void unregisterDataSetObserver(DataSetObserver dataSetObserver) {
}
@Override
public int getGroupCount() {
return ref_groupList.size();
}
@Override
public int getChildrenCount(int groupIndex) {
String group = ref_groupList.get(groupIndex);
List<String> childInfoList = ref_childListMap.get(group);
return childInfoList.size();
}
@Override
public Object getGroup(int groupIndex) {
return ref_groupList.get(groupIndex);
}
@Override
public Object getChild(int groupIndex, int childIndex) {
String group = ref_groupList.get(groupIndex);
List<String> childInfoList = ref_childListMap.get(group);
return childInfoList.get(childIndex);
}
@Override
public long getGroupId(int groupIndex) {
return groupIndex;
}
@Override
public long getChildId(int groupIndex, int childIndex) {
return childIndex;
}
@Override
public boolean hasStableIds() {
return true;
}
// This method will return a View object displayed in group list item.
@Override
public View getGroupView(int groupIndex, boolean isExpanded, View view, ViewGroup viewGroup) {
// Create the group view object.
LinearLayout groupLayoutView = new LinearLayout(context);
groupLayoutView.setOrientation(LinearLayout.HORIZONTAL);
// Create and add a textview in returned group view.
String groupText = ref_groupList.get(groupIndex);
TextView groupTextView = new TextView(context);
groupTextView.setText(groupText);
groupTextView.setTextSize(30);
groupLayoutView.addView(groupTextView);
return groupLayoutView;
}
// This method will return a View object displayed in child list item.
@Override
public View getChildView(int groupIndex, int childIndex, boolean isLastChild, View view, ViewGroup viewGroup) {
// First get child text/
Object childObj = this.getChild(groupIndex, childIndex);
String childText = (String)childObj;
// Create a TextView to display child text.
TextView childTextView = new TextView(context);
childTextView.setText(childText);
childTextView.setTextSize(20);
// childTextView.setBackgroundColor(Color.GREEN);
// Set child textview offset left. Then it will align to the right of the group image.
childTextView.setPadding(15,0,0,0);
return childTextView;
}
@Override
public boolean isChildSelectable(int groupIndex, int childIndex) {
return false;
}
@Override
public boolean areAllItemsEnabled() {
return false;
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public void onGroupExpanded(int groupIndex) {
}
@Override
public void onGroupCollapsed(int groupIndex) {
}
@Override
public long getCombinedChildId(long groupIndex, long childIndex) {
return 0;
}
@Override
public long getCombinedGroupId(long groupIndex) {
return 0;
}
}
我的主要片段是java代码
public class Main extends android.support.v4.app.Fragment {
public static List<String> ref_groupList = null;
public static Map<String, List<String>> ref_childListMap = null;
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View root=inflater.inflate(R.layout.fragment_main_page, container, false);
this.referans_linkim("Referans Linkim","12345678","kobi45678");
Exp_Ref_List_Adapter exp_ref_list_adapter=new Exp_Ref_List_Adapter(SizeOzel.this.getActivity());
final ExpandableListView exp_ref = (ExpandableListView)root.findViewById(R.id.exp_referans_linkim);
DisplayMetrics metrics = new DisplayMetrics();//for determine indicator position
SizeOzel.this.getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
int width = metrics.widthPixels;
final float scale = getResources().getDisplayMetrics().density;
int elli= (int) (50 * scale + 0.5f);
int on= (int) (10 * scale + 0.5f);
exp_ref.setIndicatorBounds(width-elli,width-on);
exp_ref.setAdapter(exp_ref_list_adapter);
// Add on group expand listener.
exp_ref.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
@Override
public void onGroupExpand(int groupIndex) {
// Get total group size.
int groupListSize = ref_groupList.size();
// Close other expanded group.
for(int i=0;i < groupListSize; i++) {
if(i!=groupIndex) {
exp_ref.collapseGroup(i);
}
}
}
});
// Referansım linkim data assign
private void referans_linkim(String name,String temsil_kod,String kobi_kod)
{
if(this.ref_groupList == null)
{
this.ref_groupList = new ArrayList<String>();
}
if(this.ref_childListMap == null)
{
this.ref_childListMap = new HashMap<String, List<String>>();
}
if(!this.ref_groupList.contains(name)) {
this.ref_groupList.add(name);
}
// Create child list.
List<String> childList = new ArrayList<String>();
childList.add("Temsilci Kodu: " + temsil_kod);
childList.add("Kobi Kodu: " + kobi_kod);
// Add child data list in the map, key is group name.
this.ref_childListMap.put(name, childList);
}
}
当我尝试扩展我的可扩展列表视图时,它会扩展。但它会压缩自己以确定宽度和高度。我想浮动可扩展列表下的项目。我该怎么办?提前致谢